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