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.SiblingRules to event bus com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus |
17 | */ |
18 | public class SiblingRulesJavaBinder 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.SiblingRules> { |
19 | |
20 | @Override |
21 | public Set<java.lang.Long> bind(com.hammurapi.eventbus.tests.familyties.rules.SiblingRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
22 | Set<java.lang.Long> ret = new HashSet<java.lang.Long>(); |
23 | |
24 | ret.add(infer(instance, bus)); |
25 | ret.add(infer0(instance, bus)); |
26 | |
27 | return ret; |
28 | } |
29 | |
30 | |
31 | private java.lang.Long infer(final com.hammurapi.eventbus.tests.familyties.rules.SiblingRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
32 | |
33 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
34 | |
35 | |
36 | predicates[0] = new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Sibling.class); |
37 | |
38 | 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>( |
39 | 1, |
40 | 0, |
41 | instance, |
42 | true, |
43 | false, |
44 | Mode.POST, |
45 | predicates) { |
46 | |
47 | @Override |
48 | 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) { |
49 | com.hammurapi.eventbus.tests.familyties.model.Sibling toPost = instance.infer( |
50 | |
51 | wrap(context), |
52 | |
53 | (com.hammurapi.eventbus.tests.familyties.model.Sibling) events[0] |
54 | ); |
55 | |
56 | |
57 | |
58 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
59 | context.post(toPost); |
60 | } |
61 | |
62 | } |
63 | |
64 | public String toString() { |
65 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Sibling com.hammurapi.eventbus.tests.familyties.rules.SiblingRules.infer(com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext,com.hammurapi.eventbus.tests.familyties.model.Sibling), cardinality="+getCardinality(); |
66 | } |
67 | |
68 | |
69 | private com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext wrap(final 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) { |
70 | return new com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext() { |
71 | |
72 | @Override |
73 | public void post(com.hammurapi.eventbus.tests.familyties.model.Relative event, Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore>... validators) { |
74 | context.post(event, validators); |
75 | } |
76 | |
77 | @Override |
78 | public com.hammurapi.eventbus.EventHandlerBase.Mode getMode() { |
79 | return context.getMode(); |
80 | } |
81 | @Override |
82 | public void consume(int index) { |
83 | context.consume(index); |
84 | } |
85 | |
86 | @Override |
87 | public void consume(com.hammurapi.eventbus.tests.familyties.model.Relative event) { |
88 | context.consume(event); |
89 | } |
90 | |
91 | @Override |
92 | public void update(com.hammurapi.eventbus.tests.familyties.model.Relative event) { |
93 | context.update(event); |
94 | } |
95 | |
96 | @Override |
97 | public void removeHandler() { |
98 | context.removeHandler(); |
99 | } |
100 | |
101 | @Override |
102 | public com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore getEventStore() { |
103 | return context.getEventStore(); |
104 | } |
105 | |
106 | |
107 | }; |
108 | } |
109 | |
110 | }; |
111 | |
112 | return bus.addHandler(eventHandler); |
113 | } |
114 | |
115 | |
116 | private java.lang.Long infer0(final com.hammurapi.eventbus.tests.familyties.rules.SiblingRules 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.CommutativeAnd(0, null, new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Child.class), new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(1), com.hammurapi.eventbus.tests.familyties.model.Child.class)), new com.hammurapi.extract.Not(new com.hammurapi.extract.Equal(0, null, new Extractor67(null), new Extractor68(null), false)), new com.hammurapi.extract.Equal(0, null, new Extractor61(null), new Extractor69(null), false)); |
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 | 2, |
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 | instance.infer( |
135 | |
136 | wrap(context), |
137 | |
138 | (com.hammurapi.eventbus.tests.familyties.model.Child) events[0], |
139 | (com.hammurapi.eventbus.tests.familyties.model.Child) events[1] |
140 | ); |
141 | |
142 | |
143 | } |
144 | |
145 | public String toString() { |
146 | return "Compiled event handler for method public void com.hammurapi.eventbus.tests.familyties.rules.SiblingRules.infer(com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext,com.hammurapi.eventbus.tests.familyties.model.Child,com.hammurapi.eventbus.tests.familyties.model.Child), cardinality="+getCardinality(); |
147 | } |
148 | |
149 | |
150 | private com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext wrap(final 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) { |
151 | return new com.hammurapi.eventbus.tests.familyties.FamilyTiesEventDispatchContext() { |
152 | |
153 | @Override |
154 | public void post(com.hammurapi.eventbus.tests.familyties.model.Relative event, Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore>... validators) { |
155 | context.post(event, validators); |
156 | } |
157 | |
158 | @Override |
159 | public com.hammurapi.eventbus.EventHandlerBase.Mode getMode() { |
160 | return context.getMode(); |
161 | } |
162 | @Override |
163 | public void consume(int index) { |
164 | context.consume(index); |
165 | } |
166 | |
167 | @Override |
168 | public void consume(com.hammurapi.eventbus.tests.familyties.model.Relative event) { |
169 | context.consume(event); |
170 | } |
171 | |
172 | @Override |
173 | public void update(com.hammurapi.eventbus.tests.familyties.model.Relative event) { |
174 | context.update(event); |
175 | } |
176 | |
177 | @Override |
178 | public void removeHandler() { |
179 | context.removeHandler(); |
180 | } |
181 | |
182 | @Override |
183 | public com.hammurapi.eventbus.tests.familyties.FamilyTiesEventStore getEventStore() { |
184 | return context.getEventStore(); |
185 | } |
186 | |
187 | |
188 | }; |
189 | } |
190 | |
191 | }; |
192 | |
193 | return bus.addHandler(eventHandler); |
194 | } |
195 | |
196 | |
197 | } |