001 package com.hammurapi.eventbus.tests;
002
003 import com.hammurapi.common.Condition;
004 import com.hammurapi.eventbus.EventHandlerBase.Mode;
005 import com.hammurapi.eventbus.Handler;
006 import com.hammurapi.eventbus.local.LocalEventDispatchContext;
007 import com.hammurapi.eventbus.tests.LocalEventBusTests.ObservableStringReference;
008
009 public class RemoveHandler2o {
010
011 private Object expectedWorld;
012
013 public void setExpectedWorld(Object expectedWorld) {
014 this.expectedWorld = expectedWorld;
015 }
016
017 private int worldCounter;
018 private boolean worldOk;
019
020 public int getWorldCounter() {
021 return worldCounter;
022 }
023
024 public boolean isWorldOk() {
025 return worldOk;
026 }
027
028 @Handler(value="java(*)://strRef.get().equals(\"World\")", mode=Mode.REMOVE)
029 public void handleWorld(ObservableStringReference strRef) {
030 ++worldCounter;
031 worldOk = expectedWorld == strRef;
032 }
033
034 private int emCounter;
035 private boolean emOk;
036
037 public int getEmCounter() {
038 return emCounter;
039 }
040
041 public boolean isEmOk() {
042 return emOk;
043 }
044
045 @Handler(mode=Mode.REMOVE)
046 public void handleEm(LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(strRef.get())") ObservableStringReference strRef) {
047 ++emCounter;
048 emOk = "!".equals(strRef.get());
049 }
050
051
052 }