cz.cuni.amis.pogamut.base.communication.command.react
Class CommandReactOnce<COMMAND extends CommandMessage>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.command.react.CommandReact<COMMAND>
      extended by cz.cuni.amis.pogamut.base.communication.command.react.CommandReactOnce<COMMAND>
Type Parameters:
COMMAND -

public abstract class CommandReactOnce<COMMAND extends CommandMessage>
extends CommandReact<COMMAND>

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

If you need to react every time, use CommandReact.

Use CommandReact.enable() and CommandReact.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.command.react.CommandReact
reactAct, reactCommandClass, reactListener
 
Constructor Summary
CommandReactOnce(java.lang.Class<COMMAND> commandClass, IAct act)
           
 
Method Summary
protected  void postReact(COMMAND event)
          Disables the reaction.
 
Methods inherited from class cz.cuni.amis.pogamut.base.communication.command.react.CommandReact
disable, enable, preReact, react
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandReactOnce

public CommandReactOnce(java.lang.Class<COMMAND> commandClass,
                        IAct act)
Method Detail

postReact

protected void postReact(COMMAND event)
Disables the reaction.

Overrides:
postReact in class CommandReact<COMMAND extends CommandMessage>