com.hammurapi.eventbus
Class MappingEventHandler<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>

Show UML class diagram
java.lang.Object
  extended by com.hammurapi.eventbus.MappingEventHandler<E,P,C,K,H,S>
Type Parameters:
E -
P -
C -
All Implemented Interfaces:
EventHandlerBase<E,P,C>, JoinEventHandler<E,P,C,K,H,S>, Serializable

public class MappingEventHandler<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>
extends Object
implements JoinEventHandler<E,P,C,K,H,S>, Serializable

Handler which maps input tuples like {{E1, E2, E5}, {E4, E3}} to {E1, E2, E3, E4, E5}

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.hammurapi.eventbus.EventHandlerBase
EventHandlerBase.Mode
 
Constructor Summary
MappingEventHandler(EventHandlerWrapper<E,P,C,K,H,S> target, Mapper<AbstractEventBus.Handle<E,P,C,K>>[] mappers)
           
 
Method Summary
 boolean consumes()
           
 int getCardinality()
           
 C getContext()
           
 EventHandlerBase.Mode getMode()
          Handler mode.
  getPredicate()
           
 P getPriority()
           
 boolean isOneOff()
          If this method returns true, then handler is invoked only once and then is removed from the bus.
 void post(EventDispatchContext<E,P,C,H,S> context, InferenceContext<E,P,C,K,H,S> inferenceContext, AbstractEventBus.Handle<E,P,C,K>[]... handles)
          Posts event for handling.
 void reset()
          Resets handler internal state, if any.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MappingEventHandler

public MappingEventHandler(EventHandlerWrapper<E,P,C,K,H,S> target,
                           Mapper<AbstractEventBus.Handle<E,P,C,K>>[] mappers)
Method Detail

consumes

public boolean consumes()
Specified by:
consumes in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:
true if this handler consumes or updates events.

getCardinality

public int getCardinality()
Specified by:
getCardinality in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:
Number of parameters expected by this handler.

getContext

public C getContext()
Specified by:
getContext in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:
Context for predicates.

getPriority

public P getPriority()
Specified by:
getPriority in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:
priority Handler priority. Handlers with higher priority are guaranteed to be executed before handlers with lower priority and as such can consume events and prevent their dispatching to other handlers.

post

public void post(EventDispatchContext<E,P,C,H,S> context,
                 InferenceContext<E,P,C,K,H,S> inferenceContext,
                 AbstractEventBus.Handle<E,P,C,K>[]... handles)
Description copied from interface: JoinEventHandler
Posts event for handling.

Specified by:
post in interface JoinEventHandler<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>
Parameters:
context - Event dispatching context.
handles - Events to handle. An event to handle if there is one event. A tuple of joined events to handle otherwise.

reset

public void reset()
Description copied from interface: EventHandlerBase
Resets handler internal state, if any.

Specified by:
reset in interface EventHandlerBase<E,P extends Comparable<P>,C>

toString

public String toString()
Overrides:
toString in class Object

isOneOff

public boolean isOneOff()
Description copied from interface: EventHandlerBase
If this method returns true, then handler is invoked only once and then is removed from the bus.

Specified by:
isOneOff in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:

getMode

public EventHandlerBase.Mode getMode()
Description copied from interface: EventHandlerBase
Handler mode.

Specified by:
getMode in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:

getPredicate

public  getPredicate()
Specified by:
getPredicate in interface EventHandlerBase<E,P extends Comparable<P>,C>
Returns:
Handler predicates.