| 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.Handler; |
| 7 | |
| 8 | public class HelperHandler { |
| 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("java(str)://str.get().equals(\"World\")") |
| 33 | public void handleWorld(AtomicReference<String> strRef) { |
| 34 | ++worldCounter; |
| 35 | worldOk = "World".equals(strRef.get()); |
| 36 | } |
| 37 | |
| 38 | @Handler //("\"!\".equals(args[0])") |
| 39 | public void handleEm(@Condition("\"!\".equals(strRef.get())") AtomicReference<String> strRef) { |
| 40 | ++emCounter; |
| 41 | emOk = "!".equals(strRef.get()); |
| 42 | } |
| 43 | } |