Class StateMachineImpl<S,E,C>
- java.lang.Object
-
- com.alibaba.cola.statemachine.impl.StateMachineImpl<S,E,C>
-
- All Implemented Interfaces:
StateMachine<S,E,C>,Visitable
public class StateMachineImpl<S,E,C> extends Object implements StateMachine<S,E,C>
For performance consideration, The state machine is made "stateless" on purpose. Once it's built, it can be shared by multi-threadOne side effect is since the state machine is stateless, we can not get current state from State Machine.
- Author:
- Frank Zhang
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringaccept(Visitor visitor)SfireEvent(S sourceStateId, E event, C ctx)Send an eventEto the state machine.StringgeneratePlantUML()StringgetMachineId()MachineId is the identifier for a State MachinevoidsetMachineId(String machineId)voidsetReady(boolean ready)voidshowStateMachine()Use visitor pattern to display the structure of the state machine
-
-
-
Method Detail
-
fireEvent
public S fireEvent(S sourceStateId, E event, C ctx)
Description copied from interface:StateMachineSend an eventEto the state machine.- Specified by:
fireEventin interfaceStateMachine<S,E,C>- Parameters:
sourceStateId- the source stateevent- the event to sendctx- the user defined context- Returns:
- the target state
-
showStateMachine
public void showStateMachine()
Description copied from interface:StateMachineUse visitor pattern to display the structure of the state machine- Specified by:
showStateMachinein interfaceStateMachine<S,E,C>
-
generatePlantUML
public String generatePlantUML()
- Specified by:
generatePlantUMLin interfaceStateMachine<S,E,C>
-
getMachineId
public String getMachineId()
Description copied from interface:StateMachineMachineId is the identifier for a State Machine- Specified by:
getMachineIdin interfaceStateMachine<S,E,C>- Returns:
-
setMachineId
public void setMachineId(String machineId)
-
setReady
public void setReady(boolean ready)
-
-