org.squirrelframework.foundation.fsm.StateMachineData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of squirrel-foundation Show documentation
Show all versions of squirrel-foundation Show documentation
foundation module of squirrel framework which provided event driven infrastructure and a finite state machine implementation.
package org.squirrelframework.foundation.fsm;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* This class is used to hold all the internal data of state machine. User can
* dump a state machine data through {@link StateMachineData#dump(Reader)} which
* means take a snapshot of state machine or save the current state machine
* execution state.
*
* @author Henry.He
*
* @param
* type of State Machine
* @param
* type of State
* @param
* type of Event
* @param
* type of Context
*/
public interface StateMachineData, S, E, C> extends Serializable {
/**
* Dump source state machine data (expect transient data, such as states)
* into current state machine data
*
* @param src
* source state machine data
*/
void dump(StateMachineData.Reader src);
/**
* @return state machine data reader
*/
Reader read();
/**
* @return state machine data writer
*/
Writer write();
public interface Reader, S, E, C> extends Serializable {
/**
* @return state machine identifier
*/
String identifier();
/**
* @return current state id of state machine
*/
S currentState();
/**
* @return last active state id of state machine
*/
S lastState();
/**
* @return id of state machine initial state
*/
S initialState();
/**
* @param parentStateId
* id of parent state
* @return last active child state of the parent state
*/
S lastActiveChildStateOf(S parentStateId);
/**
* @return all the active parent states
*/
Collection activeParentStates();
/**
* @param parentStateId
* @return sub state of parallel state
*/
List subStatesOn(S parentStateId);
/**
* @return current raw state of state machine
*/
ImmutableState currentRawState();
/**
* @return last active raw state of state machine
*/
ImmutableState lastRawState();
/**
* @return initial raw state of state machine
*/
ImmutableState initialRawState();
/**
* @param stateId
* the identify of state
* @return raw state of the same state identify
*/
ImmutableState rawStateFrom(S stateId);
/**
* @return all the parallel states
*/
Collection parallelStates();
/**
* @return type of state machine
*/
Class extends T> typeOfStateMachine();
/**
* @return type of state
*/
Class typeOfState();
/**
* @return type of event
*/
Class typeOfEvent();
/**
* @return type of context
*/
Class typeOfContext();
/**
* @return all the raw states defined in the state machine
*/
Collection> rawStates();
/**
* @return all the states defined in the state machine
*/
Collection states();
/**
* @return all linked states
*/
Collection linkedStates();
Map> orginalStates();
Reader extends StateMachine, S, E, C>, S, E, C> linkedStateDataOf(S linkedState);
}
public interface Writer, S, E, C> extends Serializable {
/**
* @return state machine identifier
*/
void identifier(String id);
/**
* Write current state of state machine data to provided state id
*
* @param currentStateId
*/
void currentState(S currentStateId);
/**
* Write last state of state machine data to provided state id
*
* @param lastStateId
*/
void lastState(S lastStateId);
/**
* Write initial state of state machine data to provided state id
*
* @param initialStateId
*/
void initalState(S initialStateId);
/**
* Set last active child state of parent state
*
* @param parentStateId
* id of parent state
* @param childStateId
* id of child state
*/
void lastActiveChildStateFor(S parentStateId, S childStateId);
/**
* Write provided sub state for provided parent state
*
* @param parentStateId
* @param subStateId
*/
void subStateFor(S parentStateId, S subStateId);
/**
* Remove provide sub state under provided parent state
*
* @param parentStateId
* @param subStateId
*/
void removeSubState(S parentStateId, S subStateId);
/**
* Remove all sub states under provider parent state
*
* @param parentStateId
*/
void removeSubStatesOn(S parentStateId);
/**
* Write type of state machine
*
* @param stateMachineType
*/
void typeOfStateMachine(Class extends T> stateMachineType);
/**
* Write type of state
*
* @param stateClass
*/
void typeOfState(Class stateClass);
/**
* Write type of event
*
* @param eventClass
*/
void typeOfEvent(Class eventClass);
/**
* Write type of context
*
* @param contextClass
*/
void typeOfContext(Class contextClass);
/**
* Write linked state data on specified linked state
*
* @param linkedState
* specified linked state
* @param linkStateData
* linked state data
*/
void linkedStateDataOn(
S linkedState,
StateMachineData.Reader extends StateMachine, S, E, C>, S, E, C> linkStateData);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy