1 | package com.hammurapi.eventbus.tests; |
2 | |
3 | import java.util.concurrent.atomic.AtomicReference; |
4 | |
5 | import com.hammurapi.common.Condition; |
6 | import com.hammurapi.eventbus.EventHandlerBase.Mode; |
7 | import com.hammurapi.eventbus.local.LocalEventDispatchContext; |
8 | import com.hammurapi.eventbus.Handler; |
9 | |
10 | public class RemoveHandler2 { |
11 | |
12 | private Object expectedWorld; |
13 | |
14 | public void setExpectedWorld(Object expectedWorld) { |
15 | this.expectedWorld = expectedWorld; |
16 | } |
17 | |
18 | private int worldCounter; |
19 | private boolean worldOk; |
20 | |
21 | public int getWorldCounter() { |
22 | return worldCounter; |
23 | } |
24 | |
25 | public boolean isWorldOk() { |
26 | return worldOk; |
27 | } |
28 | |
29 | @Handler(value="java(*)://strRef.get().equals(\"World\")", mode=Mode.REMOVE) |
30 | public void handleWorld(AtomicReference<String> strRef) { |
31 | ++worldCounter; |
32 | worldOk = expectedWorld == strRef; |
33 | } |
34 | |
35 | private int emCounter; |
36 | private boolean emOk; |
37 | |
38 | public int getEmCounter() { |
39 | return emCounter; |
40 | } |
41 | |
42 | public boolean isEmOk() { |
43 | return emOk; |
44 | } |
45 | |
46 | @Handler(mode=Mode.REMOVE) |
47 | public void handleEm( |
48 | LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(strRef.get())") AtomicReference<String> strRef) { |
49 | ++emCounter; |
50 | emOk = "!".equals(strRef.get()); |
51 | } |
52 | |
53 | |
54 | } |