Package io.hektor.fsm

Interface FSM<S extends Enum<S>,C extends Context,D extends Data>

All Known Implementing Classes:
FsmImpl

public interface FSM<S extends Enum<S>,C extends Context,D extends Data>
Author:
jonas@jonasborjesson.com
  • Method Summary

    Modifier and Type
    Method
    Description
    The state in which this FSM currently is.
    boolean
     
    boolean
    The FSM is in its terminated state if it has reached the final state.
    static <S extends Enum<S>>
    ContextTypeBuildStep<S>
    of(Class<S> type)
     
    void
    onEvent(Object event)
    Deliver an event to this FSM.
    void
    Re-start the FSM and enter the specified state.
    void
    You must call start() on the FSM before it can be used.
  • Method Details

    • start

      void start()
      You must call start() on the FSM before it can be used. This will cause the FSM to "transition" from a null state to its initial state. Any enter actions associated with the initial state will naturally now be called. Note: calling this method when the FSM is already started will silently be ignored.
    • isStarted

      boolean isStarted()
    • isTerminated

      boolean isTerminated()
      The FSM is in its terminated state if it has reached the final state.
      Returns:
    • reStartAndEnter

      void reStartAndEnter(S state) throws IllegalArgumentException
      Re-start the FSM and enter the specified state. The entry actions associated with this state will be executed. This is useful if your FSM throw an exception and you want to control how to deal with that (and potentially let the FSM start over) or if you have suspended/resumed the FSM (e.g. my serializing it to another JVM) and you want to continue were you left off.
      Parameters:
      state -
      Throws:
      IllegalArgumentException - in case the state is null
    • onEvent

      void onEvent(Object event)
      Deliver an event to this FSM.
      Parameters:
      event -
    • getState

      S getState()
      The state in which this FSM currently is.
    • of

      static <S extends Enum<S>> ContextTypeBuildStep<S> of(Class<S> type)