Class StateMachineImpl<S,​E,​C>

  • All Implemented Interfaces:
    StateMachine<S,​E,​C>, Visitable

    public class StateMachineImpl<S,​E,​C>
    extends Object
    implements StateMachine<S,​E,​C>
    For performance consideration, The state machine is made "stateless" on purpose. Once it's built, it can be shared by multi-thread

    One side effect is since the state machine is stateless, we can not get current state from State Machine.

    Author:
    Frank Zhang
    • Constructor Detail

      • StateMachineImpl

        public StateMachineImpl​(Map<S,​State<S,​E,​C>> stateMap)
    • Method Detail

      • fireEvent

        public S fireEvent​(S sourceStateId,
                           E event,
                           C ctx)
        Description copied from interface: StateMachine
        Send an event E to the state machine.
        Specified by:
        fireEvent in interface StateMachine<S,​E,​C>
        Parameters:
        sourceStateId - the source state
        event - the event to send
        ctx - the user defined context
        Returns:
        the target state
      • showStateMachine

        public void showStateMachine()
        Description copied from interface: StateMachine
        Use visitor pattern to display the structure of the state machine
        Specified by:
        showStateMachine in interface StateMachine<S,​E,​C>
      • setMachineId

        public void setMachineId​(String machineId)
      • setReady

        public void setReady​(boolean ready)