- Type Parameters:
O
- the class of the instance owning the finite state machine instanceS
- the state enumeration type uniquely identifying a state in the state machineE
- the event enumeration type uniquely identifying the event sent to the state machine
- All Superinterfaces:
Comparable<State<O,
S, E>>
The state abstraction of a hierarchical finite state machine.
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
Return the human-readable description of the state.BiConsumer
<O, Event<E>> Return the entry action of the state.Return the human-readable description for the entry action of the state.void
executeEntryAction
(O owner, Event<E> event) Execute the entry action associated with the state if defined.void
executeExitAction
(O owner, Event<E> event) Execute the exit action associated with the state if defined.BiConsumer
<O, Event<E>> Return the exit action of the state.Return the human-readable description for the exit action of the state.Return the state with the given identifier.getHierarchyFor
(State<O, S, E> substate) Return the list of all substates including this state and the given substate to reach the given substate.getStateFor
(S stateId) Return the state with the given state identifier.default boolean
Return true if the state has an entry action.default boolean
Return true if the state has an exit action.boolean
Return true if the state has history active.id()
Gets the id of this state.Return the direct substate being an initial state.Return the state machine's default initial state.default boolean
Return true if the state contains substates.default boolean
isFinal()
Return true if the state is a final state.boolean
Return true if the state is an initial state.Set
<Transition<O, S, E>> Return the list of local or self transitions starting from this state.Return the list of substates.Set
<Transition<O, S, E>> Return the list of transitions starting from this state.
-
Method Details
-
compareTo
-
id
-
hasHistory
boolean hasHistory()Return true if the state has history active.- Returns:
- flag indicating if the state has history
-
isInitial
boolean isInitial()Return true if the state is an initial state.- Returns:
- flag indicating if the state is an initial state
-
isFinal
default boolean isFinal()Return true if the state is a final state. A state is final if no transitions are leaving it.- Returns:
- flag indicating if the state is final
-
isComposite
default boolean isComposite()Return true if the state contains substates. If true, the state cannot be initial or final.- Returns:
- flag indicating if the state is composite.
-
executeEntryAction
-
executeExitAction
-
substates
-
transitions
Set<Transition<O,S, transitions()E>> Return the list of transitions starting from this state.- Returns:
- the set of transitions or an empty list if none is defined
-
localTransitions
Set<Transition<O,S, localTransitions()E>> Return the list of local or self transitions starting from this state. Self-transitions do not trigger entry or exit actions.- Returns:
- the set of self-transitions or an empty list if none is defined
-
hasEntryAction
default boolean hasEntryAction()Return true if the state has an entry action.- Returns:
- flag indicating if the state has an entry action
-
entryAction
BiConsumer<O,Event<E>> entryAction()Return the entry action of the state.- Returns:
- the action if defined otherwise null
-
hasExitAction
default boolean hasExitAction()Return true if the state has an exit action.- Returns:
- flag indicating if the state has an exit action
-
exitAction
BiConsumer<O,Event<E>> exitAction()Return the exit action of the state.- Returns:
- the action if defined otherwise null
-
getStateFor
-
initialState
-
initialStates
-
description
String description()Return the human-readable description of the state.- Returns:
- the description of the state if defined otherwise null
-
entryActionDescription
String entryActionDescription()Return the human-readable description for the entry action of the state.- Returns:
- the description of the entry action for the state if defined otherwise null
-
exitActionDescription
String exitActionDescription()Return the human-readable description for the exit action of the state.- Returns:
- the description of the exit action for state if defined otherwise null
-
getHierarchyFor
Return the list of all substates including this state and the given substate to reach the given substate. The hierarchy includes the boundary states. If not found, the list is empty.- Parameters:
substate
- substate to look for- Returns:
- the ordered hierarchy of states to reach the substate if found otherwise an empty list. The head contains the root state, the tail contains the searched substate
-
findBy
-