1 | package com.hammurapi.eventbus.tests.familyties.rules; |
2 | |
3 | import java.util.HashSet; |
4 | import java.util.Set; |
5 | |
6 | import com.hammurapi.eventbus.AbstractEventBus; |
7 | import com.hammurapi.eventbus.AbstractEventBus.Handle; |
8 | import com.hammurapi.eventbus.AbstractEventHandler; |
9 | import com.hammurapi.eventbus.EventDispatchContext; |
10 | import com.hammurapi.eventbus.EventHandler; |
11 | import com.hammurapi.eventbus.JavaBinder; |
12 | import com.hammurapi.extract.Predicate; |
13 | import com.hammurapi.eventbus.EventHandlerBase.Mode; |
14 | |
15 | /** |
16 | * Binds handler class com.hammurapi.eventbus.tests.familyties.rules.SpouseRules to event bus com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus |
17 | */ |
18 | public class SpouseRulesJavaBinder implements JavaBinder<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus, com.hammurapi.eventbus.tests.familyties.rules.SpouseRules> { |
19 | |
20 | @Override |
21 | public Set<java.lang.Long> bind(com.hammurapi.eventbus.tests.familyties.rules.SpouseRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
22 | Set<java.lang.Long> ret = new HashSet<java.lang.Long>(); |
23 | |
24 | ret.add(inferSpouse(instance, bus)); |
25 | ret.add(inferHusband(instance, bus)); |
26 | ret.add(inferWife(instance, bus)); |
27 | |
28 | return ret; |
29 | } |
30 | |
31 | |
32 | private java.lang.Long inferSpouse(final com.hammurapi.eventbus.tests.familyties.rules.SpouseRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
33 | |
34 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
35 | |
36 | |
37 | predicates[0] = new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Spouse.class); |
38 | |
39 | EventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> eventHandler = new AbstractEventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore>( |
40 | 1, |
41 | 0, |
42 | instance, |
43 | true, |
44 | false, |
45 | Mode.POST, |
46 | predicates) { |
47 | |
48 | @Override |
49 | public void post(EventDispatchContext<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> context, com.hammurapi.eventbus.tests.familyties.model.Relative... events) { |
50 | com.hammurapi.eventbus.tests.familyties.model.Spouse toPost = instance.inferSpouse( |
51 | |
52 | (com.hammurapi.eventbus.tests.familyties.model.Spouse) events[0] |
53 | ); |
54 | |
55 | |
56 | |
57 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
58 | context.post(toPost); |
59 | } |
60 | |
61 | } |
62 | |
63 | public String toString() { |
64 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Spouse com.hammurapi.eventbus.tests.familyties.rules.SpouseRules.inferSpouse(com.hammurapi.eventbus.tests.familyties.model.Spouse), cardinality="+getCardinality(); |
65 | } |
66 | |
67 | |
68 | }; |
69 | |
70 | return bus.addHandler(eventHandler); |
71 | } |
72 | |
73 | |
74 | private java.lang.Long inferHusband(final com.hammurapi.eventbus.tests.familyties.rules.SpouseRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
75 | |
76 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
77 | |
78 | |
79 | predicates[0] = new com.hammurapi.extract.And(0, null, new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Spouse.class), new Predicate10(null), new com.hammurapi.extract.Not(new com.hammurapi.extract.InstanceOfPredicate(new Extractor70(null), com.hammurapi.eventbus.tests.familyties.model.Husband.class))); |
80 | |
81 | EventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> eventHandler = new AbstractEventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore>( |
82 | 1, |
83 | 0, |
84 | instance, |
85 | true, |
86 | false, |
87 | Mode.POST, |
88 | predicates) { |
89 | |
90 | @Override |
91 | public void post(EventDispatchContext<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> context, com.hammurapi.eventbus.tests.familyties.model.Relative... events) { |
92 | com.hammurapi.eventbus.tests.familyties.model.Husband toPost = instance.inferHusband( |
93 | |
94 | (com.hammurapi.eventbus.tests.familyties.model.Spouse) events[0] |
95 | ); |
96 | |
97 | |
98 | |
99 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
100 | context.post(toPost); |
101 | } |
102 | |
103 | } |
104 | |
105 | public String toString() { |
106 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Husband com.hammurapi.eventbus.tests.familyties.rules.SpouseRules.inferHusband(com.hammurapi.eventbus.tests.familyties.model.Spouse), cardinality="+getCardinality(); |
107 | } |
108 | |
109 | |
110 | }; |
111 | |
112 | return bus.addHandler(eventHandler); |
113 | } |
114 | |
115 | |
116 | private java.lang.Long inferWife(final com.hammurapi.eventbus.tests.familyties.rules.SpouseRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
117 | |
118 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
119 | |
120 | |
121 | predicates[0] = new com.hammurapi.extract.And(0, null, new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Spouse.class), new com.hammurapi.extract.Not(new Predicate10(null)), new com.hammurapi.extract.Not(new com.hammurapi.extract.InstanceOfPredicate(new Extractor70(null), com.hammurapi.eventbus.tests.familyties.model.Wife.class))); |
122 | |
123 | EventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> eventHandler = new AbstractEventHandler<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore>( |
124 | 1, |
125 | 0, |
126 | instance, |
127 | true, |
128 | false, |
129 | Mode.POST, |
130 | predicates) { |
131 | |
132 | @Override |
133 | public void post(EventDispatchContext<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, com.hammurapi.eventbus.AbstractEventBus.Handle<com.hammurapi.eventbus.tests.familyties.model.Relative, java.lang.Integer, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules, java.lang.Long>, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore> context, com.hammurapi.eventbus.tests.familyties.model.Relative... events) { |
134 | com.hammurapi.eventbus.tests.familyties.model.Wife toPost = instance.inferWife( |
135 | |
136 | (com.hammurapi.eventbus.tests.familyties.model.Spouse) events[0] |
137 | ); |
138 | |
139 | |
140 | |
141 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
142 | context.post(toPost); |
143 | } |
144 | |
145 | } |
146 | |
147 | public String toString() { |
148 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Wife com.hammurapi.eventbus.tests.familyties.rules.SpouseRules.inferWife(com.hammurapi.eventbus.tests.familyties.model.Spouse), cardinality="+getCardinality(); |
149 | } |
150 | |
151 | |
152 | }; |
153 | |
154 | return bus.addHandler(eventHandler); |
155 | } |
156 | |
157 | |
158 | } |