001    /*
002    @license.text@
003     */
004    package com.hammurapi.eventbus.tests.familyties.rules;
005    
006    import com.hammurapi.eventbus.Handler;
007    import com.hammurapi.eventbus.tests.familyties.model.Child;
008    import com.hammurapi.eventbus.tests.familyties.model.Daughter;
009    import com.hammurapi.eventbus.tests.familyties.model.Father;
010    import com.hammurapi.eventbus.tests.familyties.model.GrandDaughter;
011    import com.hammurapi.eventbus.tests.familyties.model.GrandFather;
012    import com.hammurapi.eventbus.tests.familyties.model.GrandMother;
013    import com.hammurapi.eventbus.tests.familyties.model.GrandSon;
014    import com.hammurapi.eventbus.tests.familyties.model.Mother;
015    import com.hammurapi.eventbus.tests.familyties.model.Parent;
016    import com.hammurapi.eventbus.tests.familyties.model.Son;
017    
018    public class GrandRules extends FamilyTiesRules {
019                    
020            /**
021             * Son of child is a grandson.
022             * @param son
023             * @param parent
024             * @return
025             */
026            @Handler("java(*):// son.getObject().equals(parent.getObject())")
027            public GrandSon infer(Son son, Parent parent) {
028                    return new GrandSon(son.getSubject(), parent.getSubject());
029            }
030            
031            /**
032             * Daughter of child is a granddaughter.
033             * @param daughter
034             * @param parent
035             * @return
036             */
037            @Handler("java(*):// daughter.getObject().equals(parent.getObject())")
038            public GrandDaughter infer(Daughter daughter, Parent parent) {
039                    return new GrandDaughter(daughter.getSubject(), parent.getSubject()); 
040            }
041            
042            /**
043             * Father of parent is grandparent.
044             * @param child
045             * @param father
046             * @return
047             */
048            @Handler("java(*)://child.getObject().equals(father.getObject())")
049            public GrandFather infer(Child child, Father father) {
050                    return new GrandFather(father.getSubject(), child.getSubject());
051            }
052            
053            /**
054             * Mother of parent is grandmother.
055             * @param child
056             * @param mother
057             * @return
058             */
059            @Handler("java(child, mother)://child.getObject().equals(mother.getObject())")
060            public GrandMother infer(Child child, Mother mother) {
061                    return new GrandMother(mother.getSubject(), child.getSubject());
062            }
063            
064    }