org.apache.mina.statemachine.transition

## 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`.
  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractTransition(Object eventId)` Creates a new instance which will loopback to the same `State` for the specified `Event` id.
    `AbstractTransition(Object eventId, State nextState)` Creates a new instance with the specified `State` as next state and for the specified `Event` id.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `doExecute(Event event)` Executes this `Transition`.
    `boolean` | `equals(Object o)`
    `boolean` | `execute(Event event)` Executes this `Transition`.
    `State` | `getNextState()` Returns the `State` which the `StateMachine` should move to if this `Transition` is taken and `Transition.execute(Event)` returns `true`.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### 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`.

  - ### Method Detail

    - #### getNextState

          public State getNextState()

      Description copied from interface: `Transition`
      Returns the `State` which the `StateMachine` should move to if this `Transition` is taken and `Transition.execute(Event)` returns `true`.
      Specified by:
        `getNextState` in interface `Transition`
      Returns:
        the next `State` or `null` if this `Transition` is a loopback `Transition`.

    - #### execute

          public boolean execute(Event event)

      Description copied from interface: `Transition`
      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.
      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`

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.