1 | package com.hammurapi.eventbus.tests; |
2 | |
3 | import com.hammurapi.common.Condition; |
4 | import com.hammurapi.eventbus.EventHandlerBase.Mode; |
5 | import com.hammurapi.eventbus.Handler; |
6 | import com.hammurapi.eventbus.local.LocalEventDispatchContext; |
7 | |
8 | public class RemoveHandler { |
9 | |
10 | private int worldCounter; |
11 | private boolean worldOk; |
12 | |
13 | private int emCounter; |
14 | private boolean emOk; |
15 | |
16 | public int getWorldCounter() { |
17 | return worldCounter; |
18 | } |
19 | |
20 | public boolean isWorldOk() { |
21 | return worldOk; |
22 | } |
23 | |
24 | public int getEmCounter() { |
25 | return emCounter; |
26 | } |
27 | |
28 | public boolean isEmOk() { |
29 | return emOk; |
30 | } |
31 | |
32 | @Handler(value="java(str)://str.equals(\"World\")", mode=Mode.REMOVE) |
33 | public void handleWorld(String str) { |
34 | ++worldCounter; |
35 | worldOk = "World".equals(str); |
36 | } |
37 | |
38 | @Handler(mode=Mode.REMOVE) //("\"!\".equals(args[0])") |
39 | public void handleEm(LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(str)") String str) { |
40 | ++emCounter; |
41 | emOk = "!".equals(str); |
42 | context.post("Bye!"); |
43 | } |
44 | |
45 | |
46 | } |