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.ParentChildRules to event bus com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus |
17 | */ |
18 | public class ParentChildRulesJavaBinder 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.ParentChildRules> { |
19 | |
20 | @Override |
21 | public Set<java.lang.Long> bind(com.hammurapi.eventbus.tests.familyties.rules.ParentChildRules 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.ParentChildRules 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.Parent.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.Child toPost = instance.infer( |
50 | |
51 | (com.hammurapi.eventbus.tests.familyties.model.Parent) events[0] |
52 | ); |
53 | |
54 | |
55 | |
56 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
57 | context.post(toPost); |
58 | } |
59 | |
60 | } |
61 | |
62 | public String toString() { |
63 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Child com.hammurapi.eventbus.tests.familyties.rules.ParentChildRules.infer(com.hammurapi.eventbus.tests.familyties.model.Parent), cardinality="+getCardinality(); |
64 | } |
65 | |
66 | |
67 | }; |
68 | |
69 | return bus.addHandler(eventHandler); |
70 | } |
71 | |
72 | |
73 | private java.lang.Long infer0(final com.hammurapi.eventbus.tests.familyties.rules.ParentChildRules instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
74 | |
75 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
76 | |
77 | |
78 | predicates[0] = new com.hammurapi.extract.InstanceOfPredicate(new com.hammurapi.extract.IndexedExtractor(0), com.hammurapi.eventbus.tests.familyties.model.Child.class); |
79 | |
80 | 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>( |
81 | 1, |
82 | 0, |
83 | instance, |
84 | true, |
85 | false, |
86 | Mode.POST, |
87 | predicates) { |
88 | |
89 | @Override |
90 | 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) { |
91 | com.hammurapi.eventbus.tests.familyties.model.Parent toPost = instance.infer( |
92 | |
93 | (com.hammurapi.eventbus.tests.familyties.model.Child) events[0] |
94 | ); |
95 | |
96 | |
97 | |
98 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
99 | context.post(toPost); |
100 | } |
101 | |
102 | } |
103 | |
104 | public String toString() { |
105 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Parent com.hammurapi.eventbus.tests.familyties.rules.ParentChildRules.infer(com.hammurapi.eventbus.tests.familyties.model.Child), cardinality="+getCardinality(); |
106 | } |
107 | |
108 | |
109 | }; |
110 | |
111 | return bus.addHandler(eventHandler); |
112 | } |
113 | |
114 | |
115 | } |