Interface FsmContext<S,​E>

  • All Known Subinterfaces:
    ActionContext<S,​E>

    public interface FsmContext<S,​E>
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  FsmContext.Key<T>  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      S currentState()
      Get the current state of the FSM.
      void fireEvent​(E event)
      Fire an event to be evaluated against the current state of the Fsm.
      java.lang.Object get​(FsmContext.Key<?> key)
      Get the value identified by key from the context, or null if it does not exist.
      long getInstanceId()
      Get the id assigned to this FSM instance.
      void processShelvedEvents()
      Drain the event shelf of any queued events and fire them for evaluation.
      java.lang.Object remove​(FsmContext.Key<?> key)
      Get and remove the value identified by key from the context, or null if it does not exist.
      void set​(FsmContext.Key<?> key, java.lang.Object value)
      Set a value identified by key on the context.
      void shelveEvent​(E event)
      Shelve an event to to be evaluated at some later time.
    • Method Detail

      • currentState

        S currentState()
        Get the current state of the FSM.
        Returns:
        the current state of the FSM.
      • fireEvent

        void fireEvent​(E event)
        Fire an event to be evaluated against the current state of the Fsm.
        Parameters:
        event - the event to be evaluated.
      • shelveEvent

        void shelveEvent​(E event)
        Shelve an event to to be evaluated at some later time.

        This is useful e.g. when an event can't be handled in the current state but shouldn't be discarded or ignored with an action-less internal transition.

        Parameters:
        event - the event to be queued.
        See Also:
        processShelvedEvents()
      • processShelvedEvents

        void processShelvedEvents()
        Drain the event shelf of any queued events and fire them for evaluation.
      • get

        java.lang.Object get​(FsmContext.Key<?> key)
        Get the value identified by key from the context, or null if it does not exist.
        Parameters:
        key - the FsmContext.Key.
        Returns:
        the value identified by key, or null if it does not exist.
      • remove

        java.lang.Object remove​(FsmContext.Key<?> key)
        Get and remove the value identified by key from the context, or null if it does not exist.
        Parameters:
        key - the FsmContext.Key.
        Returns:
        the value identified by key, or null if it did not exist.
      • set

        void set​(FsmContext.Key<?> key,
                 java.lang.Object value)
        Set a value identified by key on the context.
        Parameters:
        key - the FsmContext.Key.
        value - the value.
      • getInstanceId

        long getInstanceId()
        Get the id assigned to this FSM instance.

        The id is a monotonically increasing value assigned to each new instance to aid in determining which log messages belong to which instance.

        Returns:
        the id assigned to this FSM instance.