Class AbstractTransition

java.lang.Object
org.apache.mina.statemachine.transition.AbstractTransition
All Implemented Interfaces:
Transition
Direct Known Subclasses:
MethodTransition, NoopTransition

public abstract class AbstractTransition extends Object implements Transition
Abstract Transition implementation. Takes care of matching the current Event's id against the id of the Event this Transition handles. To handle any Event the id should be set to Event.WILDCARD_EVENT_ID.
  • Field Details

    • eventId

      private final Object eventId
      The accepted event ID
    • nextState

      private final State nextState
      The next state, if any
  • Constructor Details

    • AbstractTransition

      public AbstractTransition(Object eventId)
      Creates a new instance which will loopback to the same State for the specified Event id.
      Parameters:
      eventId - the Event id.
    • AbstractTransition

      public AbstractTransition(Object eventId, State nextState)
      Creates a new instance with the specified State as next state and for the specified Event id.
      Parameters:
      eventId - the Event id.
      nextState - the next State.
    • AbstractTransition

      public AbstractTransition(State nextState)
      Creates a new instance with the specified State as next state and for the wild card Event id.
      Parameters:
      nextState - the next State.
    • AbstractTransition

      public AbstractTransition()
      Creates a new instance with a reflexive State as next state and for the wild card Event id.
  • Method Details

    • getNextState

      public State getNextState()
      Specified by:
      getNextState in interface Transition
      Returns:
      the State which the StateMachine should move to if this Transition is taken and Transition.execute(Event) returns true. null if this Transition is a loopback Transition.
    • execute

      public boolean execute(Event event)
      Executes this Transition. It is the responsibility of this Transition to determine whether it actually applies for the specified Event. If this Transition doesn't apply nothing should be executed and false must be returned. The method will accept any Event if it is registered with the wild card event ID ('*'), and the event ID it is declared for (ie, the event ID that has been passed as a parameter to this transition constructor.)
      Specified by:
      execute in interface Transition
      Parameters:
      event - the current Event.
      Returns:
      true if the Transition was executed, false otherwise.
    • doExecute

      protected abstract boolean doExecute(Event event)
      Executes this Transition. This method doesn't have to check if the Event's id matches because execute(Event) has already made sure that that is the case.
      Parameters:
      event - the current Event.
      Returns:
      true if the Transition has been executed successfully and the StateMachine should move to the next State. false otherwise.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object