Class StateModel<S extends Enum<S>>

  • Type Parameters:
    S - the type of the states; must be an enumeration type
    All Implemented Interfaces:
    Action
    Direct Known Subclasses:
    LevelControl

    public abstract class StateModel<S extends Enum<S>>
    extends Object
    implements Action
    Base class for implementing state transition models. State transition models have a set of states and state transitions. Provides methods for implementing the DSL for state transitions models.
    Author:
    Herbert Praehofer
    • Constructor Detail

      • StateModel

        protected StateModel​(S[] states,
                             S initial)
        Constructor initializing the set of states and the initial state.
        Parameters:
        states - the set of states
        initial - the initial state
    • Method Detail

      • inState

        protected StateModel.State inState​(S s)
        Tests if the given state is the current state.
        Parameters:
        s - the state to test if it is the current state
        Returns:
        true if the state is the current state
      • nextState

        protected void nextState​(S s)
        Sets the current state to the given state.
        Parameters:
        s - the new current state
      • exec

        public void exec()
        Executes the model by executing the current state object.
        Specified by:
        exec in interface Action