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

Package class diagram package EventFilter
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 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.

Author:
Jimmy

Constructor Summary
EventFilter(Class<T> eventClass)
           
EventFilter(Class<T> eventClass, Class<? extends IComponent> componentClass)
           
EventFilter(Class<T> eventClass, cz.cuni.amis.utils.token.Token componentId)
           
 
Method Summary
 boolean accept(T event)
          Whether the event may be accepted.
 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).
 cz.cuni.amis.utils.token.Token getComponentId()
          If it does not return null - then only events from the component of this id may be accepted.
 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(Class<T> eventClass)
Parameters:
eventClass - which events should be examined inside EventFilter#accept(IComponentEvent)

EventFilter

public EventFilter(Class<T> eventClass,
                   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(Class<T> eventClass,
                   cz.cuni.amis.utils.token.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 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 cz.cuni.amis.utils.token.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 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:


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.