001    package com.hammurapi.eventbus.tests;
002    
003    import com.hammurapi.common.Condition;
004    import com.hammurapi.eventbus.Handler;
005    import com.hammurapi.eventbus.local.LocalEventDispatchJoinContext;
006    
007    public class JoinHandlerWithCost {
008            
009            private int joinCounter;
010            private boolean joinOk; 
011            
012            public boolean isJoinOk() {
013                    return joinOk;
014            }
015            
016            public int getJoinCounter() {
017                    return joinCounter;
018            }
019    
020            @Handler({
021                            "java(,world,)://world.equals(\"World\")",
022                            "java(hello,world,i)://AND(i+((int) 'A')> (int) hello.charAt(0),i+((int) 'A')< (int) world.charAt(0))"
023                    })
024            public void join(
025                            LocalEventDispatchJoinContext<Object, Integer, Object> context, 
026                            @Condition("COST(2*20,\"Hello\".equals(hello))") String hello, 
027                            String world, 
028                            int i) {
029                    ++joinCounter;
030                    joinOk = "Hello".equals(hello) && "World".equals(world) && i>'H'-'A' && i<'W'-'A';
031                    
032                    context.post(hello+" "+world+" "+i);
033            }
034    }