public interface FsmContext<S,E>
| Modifier and Type | Interface and Description |
|---|---|
static class |
FsmContext.Key<T> |
| Modifier and Type | Method and 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.
|
S currentState()
void fireEvent(E event)
Fsm.event - the event to be evaluated.void shelveEvent(E event)
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.
event - the event to be queued.processShelvedEvents()void processShelvedEvents()
java.lang.Object get(FsmContext.Key<?> key)
key from the context, or null if it does not exist.key - the FsmContext.Key.key, or null if it does not exist.java.lang.Object remove(FsmContext.Key<?> key)
key from the context, or null if it does not exist.key - the FsmContext.Key.key, or null if it did not exist.void set(FsmContext.Key<?> key, java.lang.Object value)
key on the context.key - the FsmContext.Key.value - the value.long getInstanceId()
The id is a monotonically increasing value assigned to each new instance to aid in determining which log messages belong to which instance.