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.DaughterRule to event bus com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus |
17 | */ |
18 | public class DaughterRuleJavaBinder 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.DaughterRule> { |
19 | |
20 | @Override |
21 | public Set<java.lang.Long> bind(com.hammurapi.eventbus.tests.familyties.rules.DaughterRule 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 | |
26 | return ret; |
27 | } |
28 | |
29 | |
30 | private java.lang.Long infer(final com.hammurapi.eventbus.tests.familyties.rules.DaughterRule instance, com.hammurapi.eventbus.tests.familyties.FamilyTiesEventBus bus) { |
31 | |
32 | Predicate<com.hammurapi.eventbus.tests.familyties.model.Relative, com.hammurapi.eventbus.tests.familyties.rules.FamilyTiesRules>[] predicates = new Predicate[1]; |
33 | |
34 | |
35 | 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.Child.class), new com.hammurapi.extract.Not(new com.hammurapi.extract.InstanceOfPredicate(new Extractor57(null), com.hammurapi.eventbus.tests.familyties.model.Daughter.class)), new com.hammurapi.extract.Not(new Predicate9(null))); |
36 | |
37 | 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>( |
38 | 1, |
39 | 0, |
40 | instance, |
41 | true, |
42 | false, |
43 | Mode.POST, |
44 | predicates) { |
45 | |
46 | @Override |
47 | 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) { |
48 | com.hammurapi.eventbus.tests.familyties.model.Daughter toPost = instance.infer( |
49 | |
50 | (com.hammurapi.eventbus.tests.familyties.model.Child) events[0] |
51 | ); |
52 | |
53 | if (com.hammurapi.eventbus.tests.familyties.model.Relative.class.isInstance(toPost)) { |
54 | context.post(toPost); |
55 | } |
56 | |
57 | } |
58 | |
59 | public String toString() { |
60 | return "Compiled event handler for method public com.hammurapi.eventbus.tests.familyties.model.Daughter com.hammurapi.eventbus.tests.familyties.rules.DaughterRule.infer(com.hammurapi.eventbus.tests.familyties.model.Child), cardinality="+getCardinality(); |
61 | } |
62 | |
63 | |
64 | }; |
65 | |
66 | return bus.addHandler(eventHandler); |
67 | } |
68 | |
69 | |
70 | } |