EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.eventbus.tests.familyties.rules]

COVERAGE SUMMARY FOR SOURCE FILE [SiblingRules.java]

nameclass, %method, %block, %line, %
SiblingRules.java100% (1/1)100% (3/3)100% (65/65)100% (11/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SiblingRules100% (1/1)100% (3/3)100% (65/65)100% (11/11)
SiblingRules (): void 100% (1/1)100% (3/3)100% (1/1)
infer (FamilyTiesEventDispatchContext, Child, Child): void 100% (1/1)100% (23/23)100% (3/3)
infer (FamilyTiesEventDispatchContext, Sibling): Sibling 100% (1/1)100% (39/39)100% (7/7)

1/*
2@license.text@
3 */
4package com.hammurapi.eventbus.tests.familyties.rules;
5 
6import com.hammurapi.eventbus.Handler;
7import com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext;
8import com.hammurapi.eventbus.tests.familyties.model.Brother;
9import com.hammurapi.eventbus.tests.familyties.model.Child;
10import com.hammurapi.eventbus.tests.familyties.model.Sibling;
11import com.hammurapi.eventbus.tests.familyties.model.Sister;
12 
13public class SiblingRules extends FamilyTiesRules {        
14        
15        /**
16         * Male sibling is brother, female sibling is sister.
17         * If A is a sibling of B then B is a sibling of A.
18         * @param sibling
19         * @return Brother or Sister.
20         */
21        @Handler(posts={Sibling.class, Brother.class, Sister.class})
22        public Sibling infer(FamilyTiesEventDispatchContext dispatchContext, Sibling sibling) {        
23                dispatchContext.post(new Sibling(sibling.getObject(), sibling.getSubject()));
24                
25                if (sibling.getSubject().isMale()) {
26                        if (!(sibling instanceof Brother)) {
27                                return new  Brother(sibling.getSubject(), sibling.getObject());
28                        }                        
29                } else {
30                        if (!(sibling instanceof Sister)) {
31                                return new Sister(sibling.getSubject(), sibling.getObject());
32                        }                        
33                }
34                return null;
35        }
36 
37        /**
38         * If two children have common parent then they are siblings.
39         * @param child
40         * @param anotherChild
41         */
42        @Handler(value="java(*)://!child.getSubject().equals(anotherChild.getSubject()) && child.getObject().equals(anotherChild.getObject())",        posts=Sibling.class)
43        public void infer(FamilyTiesEventDispatchContext dispatchContext, Child child, Child anotherChild) {
44                dispatchContext.post(new Sibling(child.getSubject(), anotherChild.getSubject()));
45                dispatchContext.post(new Sibling(anotherChild.getSubject(), child.getSubject()));
46        }
47}

[all classes][com.hammurapi.eventbus.tests.familyties.rules]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov