public interface Fsm<S,E>
| Modifier and Type | Method and Description |
|---|---|
void |
fireEvent(E event)
Fire an event for the FSM to evaluate.
|
void |
fireEvent(E event,
java.util.function.Consumer<S> stateConsumer)
Fire an event for the FSM to evaluate, providing a callback that will be invoked when the event is evaluated.
|
S |
fireEventBlocking(E event)
Fire an event for the FSM to evaluate and block waiting until the state transitioned to as a result of
evaluating
event is available. |
<T> T |
getFromContext(java.util.function.Function<FsmContext<S,E>,T> get)
Provides safe access to the
FsmContext in order to retrieve a value from it. |
S |
getState()
Get the current state of the FSM.
|
S getState()
void fireEvent(E event)
The subsequent state transition may occur asynchronously. There is no guarantee that a subsequent call to
getState() reflects a state arrived at via evaluation of this event.
event - the event to evaluate.fireEvent(Object, Consumer)void fireEvent(E event, java.util.function.Consumer<S> stateConsumer)
event - the event to evaluate.stateConsumer - the callback that will receive the state transitioned to via evaluation of event.S fireEventBlocking(E event) throws java.lang.InterruptedException
event is available.event - the event to evaluate.event.java.lang.InterruptedException - if interrupted while blocking.<T> T getFromContext(java.util.function.Function<FsmContext<S,E>,T> get)
FsmContext in order to retrieve a value from it.T - the type of the value being retrieved.get - the Function provided access to the context.context.