cz.cuni.amis.pogamut.base.communication.worldview.react
Class EventReactOnce<EVENT extends IWorldEvent>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.worldview.react.EventReact<EVENT>
      extended by cz.cuni.amis.pogamut.base.communication.worldview.react.EventReactOnce<EVENT>
Type Parameters:
EVENT -

public abstract class EventReactOnce<EVENT extends IWorldEvent>
extends EventReact<EVENT>

This abstract class allows you to easily hook a specific event-handling behavior. It automatically register a listener for a specified IWorldEvent for you and calls EventReact.react(IWorldEvent) method automatically. The EventReact.react(IWorldEvent) will be called only once (upon first event received).

If you need to react every time, use EventReact.

Use EventReact.enable() and EventReact.disable() to enable react / disable react. The reaction is enabled as default. WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to listeners and if you do not save pointer to the object, it will be gc()ed!


Field Summary
 
Fields inherited from class cz.cuni.amis.pogamut.base.communication.worldview.react.EventReact
reactEventClass, reactListener, reactWorldView
 
Constructor Summary
EventReactOnce(java.lang.Class<EVENT> eventClass, IWorldView worldView)
           
 
Method Summary
protected  void postReact(EVENT event)
          Disables the reaction.
 
Methods inherited from class cz.cuni.amis.pogamut.base.communication.worldview.react.EventReact
disable, enable, preReact, react
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventReactOnce

public EventReactOnce(java.lang.Class<EVENT> eventClass,
                      IWorldView worldView)
Method Detail

postReact

protected void postReact(EVENT event)
Disables the reaction.

Overrides:
postReact in class EventReact<EVENT extends IWorldEvent>