cz.cuni.amis.pogamut.base.component.bus.event
Class EventFilter<T>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.component.bus.event.EventFilter<T>
Type Parameters:
T -
All Implemented Interfaces:
WaitForEvent.IEventFilter<T>

public class EventFilter<T>
extends java.lang.Object
implements WaitForEvent.IEventFilter<T>

Class for accepting events - provides description of which event should be checked and method that performs the check.

Preferred way of usage are anonymous classes which override EventFilter#accept(IComponentEvent) that otherwise always return null.


Constructor Summary
EventFilter(java.lang.Class<T> eventClass)
           
EventFilter(java.lang.Class<T> eventClass, java.lang.Class<? extends IComponent> componentClass)
           
EventFilter(java.lang.Class<T> eventClass, Token componentId)
           
 
Method Summary
 boolean accept(T event)
          Whether the event may be accepted.
 java.lang.Class getComponentClass()
          If it does not return null - then only events that happened on this class of component may be accepted (this class or descendants).
 Token getComponentId()
          If it does not return null - then only events from the component of this id may be accepted.
 java.lang.Class<T> getEventClass()
          Must return class of the event that the object may accept.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventFilter

public EventFilter(java.lang.Class<T> eventClass)
Parameters:
eventClass - which events should be examined inside EventFilter#accept(IComponentEvent)

EventFilter

public EventFilter(java.lang.Class<T> eventClass,
                   java.lang.Class<? extends IComponent> componentClass)
Parameters:
eventClass - which events should be examined inside EventFilter#accept(IComponentEvent)
componentClass - from which component class the events are examined inside EventFilter#accept(IComponentEvent)

EventFilter

public EventFilter(java.lang.Class<T> eventClass,
                   Token componentId)
Parameters:
eventClass - which events should be examined inside EventFilter#accept(IComponentEvent)
componentId - from which component id the events are examined inside EventFilter#accept(IComponentEvent)
Method Detail

accept

public boolean accept(T event)
Description copied from interface: WaitForEvent.IEventFilter
Whether the event may be accepted.

Specified by:
accept in interface WaitForEvent.IEventFilter<T>
Returns:

getComponentClass

public java.lang.Class getComponentClass()
Description copied from interface: WaitForEvent.IEventFilter
If it does not return null - then only events that happened on this class of component may be accepted (this class or descendants).

Specified by:
getComponentClass in interface WaitForEvent.IEventFilter<T>
Returns:

getComponentId

public Token getComponentId()
Description copied from interface: WaitForEvent.IEventFilter
If it does not return null - then only events from the component of this id may be accepted.

Specified by:
getComponentId in interface WaitForEvent.IEventFilter<T>
Returns:

getEventClass

public java.lang.Class<T> getEventClass()
Description copied from interface: WaitForEvent.IEventFilter
Must return class of the event that the object may accept.

Must not return null!

Specified by:
getEventClass in interface WaitForEvent.IEventFilter<T>
Returns: