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.
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 Summary
Modifier and TypeMethodDescriptiondefault StateActionandThen(StateAction after) Chains this action with another.voidexecute(StateMachineContext context) Executes the action.static StateActionnoop()Creates a no-op action.
-
Method Details
-
execute
Executes the action.- Parameters:
context- the state machine context
-
noop
Creates a no-op action.- Returns:
- no-op action
-
andThen
Chains this action with another.- Parameters:
after- the action to run after this one- Returns:
- combined action
-