Package com.tnsai.fsm

Interface StateAction

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StateAction
Functional interface for state entry/exit actions.

Actions are executed when entering or exiting a state.

Usage


 StateAction logEntry = ctx -> {
     System.out.println("Entering state: " + ctx.getCurrentState().getName());
 };

 StateAction updateStatus = ctx -> {
     ctx.set("status", "active");
 };
 
  • Method Details

    • execute

      void execute(StateMachineContext context)
      Executes the action.
      Parameters:
      context - the state machine context
    • noop

      static StateAction noop()
      Creates a no-op action.
      Returns:
      no-op action
    • andThen

      default StateAction andThen(StateAction after)
      Chains this action with another.
      Parameters:
      after - the action to run after this one
      Returns:
      combined action