public final class FSM extends java.lang.Object
FSMis a complete implementation of a finite state machine (a.k.a. deterministic finite automaton). The FSM is represented as a
Map, so clients will need to provide a properly formatted
Mapobject to initialize the FSM. The recommended way to build this
Mapis to use the
FSMBuilderclass, which provides an API abstraction for building the FSM data structure.
FSM returns an
FSMStateInfo every time a
client class asks for the next or previous state. The interpretation
FSMStateInfo object's contents is left to the
client class's implementation.
FSM encapsulates fairly complex behavior. An
FSMhas halted. By definition, a halted FSM is one that has completed its final state (and a particular FSM specification may contain more than one final state). A final state is said to be "completed" when its activity (represented by the
Step) has finished and Step's
Traversabledoes not specify an exit transition that leaves the final state.
This means that it is possible to transition out of a final state into a non-final state or even another final state. The computational model for deterministic finite automata (DFA) allows for this, so this implementation simply follows suit. From a practical standpoint, most FSM's should need only one final state, and implementors should strive to have only one final state (with no transitions out of it) unless there is a specific feature that cannot be implemented otherwise.
The design of this class and its methods are based on the concepts behind the UML State Machine diagram, the UML Activity diagram, and the computational model of a deterministic finite automaton.