Package dev.prozilla.pine.core.state
Class StateMachine<Context,State extends State<Context>>
java.lang.Object
dev.prozilla.pine.core.state.StateMachine<Context,State>
- All Implemented Interfaces:
MutableStateProvider<Context,,State> StateProvider<Context,State>
public class StateMachine<Context,State extends State<Context>>
extends Object
implements MutableStateProvider<Context,State>
Utility class for managing a finite-state machine (FSM).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStateMachine(State initialState, Context context) Creates a state machine for a given context and enters its initial state. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.prozilla.pine.core.state.MutableStateProvider
changeState, toggleStateMethods inherited from interface dev.prozilla.pine.core.state.StateProvider
isAnyState, isState
-
Field Details
-
currentState
-
context
-
-
Constructor Details
-
StateMachine
Creates a state machine for a given context and enters its initial state.- Parameters:
initialState- The initial state of the state machinecontext- The context of the state
-
-
Method Details
-
changeState
Description copied from interface:MutableStateProviderExits the current state and enters a new state, unless both are equal.- Specified by:
changeStatein interfaceMutableStateProvider<Context,State extends State<Context>> - Parameters:
newState- The new state to enter
-
getState
-
getLogger
-