1 | package com.hammurapi.eventbus.tests; |
2 | |
3 | import com.hammurapi.common.Condition; |
4 | import com.hammurapi.eventbus.Handler; |
5 | import com.hammurapi.eventbus.local.LocalEventDispatchContext; |
6 | |
7 | public class ParameterNamesJoinHandler { |
8 | |
9 | private int helloCounter; |
10 | private boolean helloOk; |
11 | |
12 | public int getHelloCounter() { |
13 | return helloCounter; |
14 | } |
15 | |
16 | public boolean isHelloOk() { |
17 | return helloOk; |
18 | } |
19 | |
20 | private int joinCounter; |
21 | private boolean joinOk; |
22 | |
23 | public boolean isJoinOk() { |
24 | return joinOk; |
25 | } |
26 | |
27 | public int getJoinCounter() { |
28 | return joinCounter; |
29 | } |
30 | |
31 | @Handler("java(*)://str.equals(\"Hello\")") |
32 | public String handleHello(String str) { |
33 | ++helloCounter; |
34 | helloOk = "Hello".equals(str); |
35 | return "World"; |
36 | } |
37 | |
38 | @Handler({ |
39 | "java(*)://world.equals(\"World\")", |
40 | "java(*)://AND(i+((int) 'A')> (int) hello.charAt(0),i+((int) 'A')< (int) world.charAt(0))" |
41 | }) |
42 | public void join( |
43 | LocalEventDispatchContext<Object, Integer, Object> context, |
44 | @Condition("\"Hello\".equals(hello)") String hello, |
45 | String world, |
46 | int i) { |
47 | ++joinCounter; |
48 | joinOk = "Hello".equals(hello) && "World".equals(world) && i>'H'-'A' && i<'W'-'A'; |
49 | } |
50 | } |