org.squirrelframework.foundation.fsm.StateMachineBuilder 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 org.squirrelframework.foundation.fsm.builder.*;
/**
* State machine builder API.
*
* @author Henry.He
*
* @param The type of implemented state machine
* @param The type of implemented state
* @param The type of implemented event
* @param The type of implemented context
*/
public interface StateMachineBuilder, S, E, C> {
/**
* Start to build external transition
* @return External transition builder
*/
ExternalTransitionBuilder externalTransition();
/**
* Create multiple external transitions builder with default priority
* @return multiple external transitions builder
*/
MultiTransitionBuilder externalTransitions();
/**
* Start to build external transition, same as externalTransition
* @return External transition builder
*/
ExternalTransitionBuilder transition();
/**
* The same as externalTransitions
* @return multiple external transitions builder
*/
MultiTransitionBuilder transitions();
/**
* Create defer bound action builder
* @return defer bound action builder
*/
DeferBoundActionBuilder transit();
/**
* Start to build local transition
* @return Local transition builder
*/
LocalTransitionBuilder localTransition();
/**
* Create multiple local transitions builder with default priority
* @return multiple local transitions builder
*/
MultiTransitionBuilder localTransitions();
/**
* Start to build internal transition
* @return Internal transition builder
*/
InternalTransitionBuilder internalTransition();
/**
* Create external transition builder with priority
* @param priority external transition priority
* @return external transition builder with priority
*/
ExternalTransitionBuilder externalTransition(int priority);
/**
* Create multiple external transitions builder with priority
* @param priority external transitions priority
* @return multiple external transitions builder
*/
MultiTransitionBuilder externalTransitions(int priority);
/**
* Same as externalTransition
* @param priority transition priority
* @return External transition builder
*/
ExternalTransitionBuilder transition(int priority);
/**
* the same as externalTransitions
* @param priority external transitions priority
* @return multiple external transitions builder
*/
MultiTransitionBuilder transitions(int priority);
/**
* Create local transition builder with priority
* @param priority local transition priority
* @return local transition builder
*/
LocalTransitionBuilder localTransition(int priority);
/**
* Create multiple local transitions builder with priority
* @param priority local transition priority
* @return local transition builder
*/
MultiTransitionBuilder localTransitions(int priority);
/**
* Create internal transition builder with priority
* @param priority internal transition priority
* @return internal transition
*/
InternalTransitionBuilder internalTransition(int priority);
/**
* Define a new state in state machine model
* @param stateId id of new state
* @return defined new mutable state
*/
MutableState defineState(S stateId);
/**
* Define a final state in state machine model
* @param stateId id of final state
* @return defined final state
*/
MutableState defineFinalState(S stateId);
/**
* Define a linked state
* @param stateId id of linked state
* @param linkedStateMachineBuilder linked state machine builder
* @param initialLinkedState initial linked state
* @param extraParams additional parameters used to create linked state machine
* @return linked state
*/
MutableState defineLinkedState(S stateId,
StateMachineBuilder extends StateMachine, S, E, C>, S, E, C> linkedStateMachineBuilder,
S initialLinkedState, Object... extraParams);
/**
* Define a timed state
* @param stateId state id
* @param initialDelay initial delay ms
* @param timeInterval time period if null not repeat
* @param autoEvent
* @param autoContext
* @return timed state
*/
MutableState defineTimedState(S stateId, long initialDelay,
long timeInterval, E autoEvent, C autoContext);
/**
* Define sequential child states whose hierarchy type is default set to NONE on parent state
* @param parentStateId id of parent state
* @param childStateIds child states id of parent state. The first child state will be used as initial child state of parent state.
*/
void defineSequentialStatesOn(S parentStateId, S... childStateIds);
/**
* Define sequential child states on parent state
*
* @param parentStateId id of parent state
* @param historyType history type of parent state
* @param childStateIds child states id of parent state. The first child state will be used as initial child state of parent state.
*/
void defineSequentialStatesOn(S parentStateId, HistoryType historyType, S... childStateIds);
/**
* Define sequential child states on parent state without initial state
* @param parentStateId id of parent state
* @param childStateIds child states id of parent state
*/
void defineNoInitSequentialStatesOn(S parentStateId, S... childStateIds);
/**
* Define sequential child states on parent state without initial state
* @param parentStateId id of parent state
* @param historyType history type of parent state
* @param childStateIds child states id of parent state
*/
void defineNoInitSequentialStatesOn(S parentStateId, HistoryType historyType, S... childStateIds);
/**
* Define sequential child states on parent state. For parallel state the history type always be none.
*
* @param parentStateId id of parent state
* @param childStateIds child states id of parent state. The first child state will be used as initial child state of parent state.
*/
void defineParallelStatesOn(S parentStateId, S... childStateIds);
/**
* Define event for parallel transition finished
* @param finishEvent
*/
void defineFinishEvent(E finishEvent);
/**
* Define event for state machine started
* @param startEvent
*/
void defineStartEvent(E startEvent);
/**
* Define event for state machine terminated
* @param terminateEvent
*/
void defineTerminateEvent(E terminateEvent);
/**
* Define on entry actions for state
* @param stateId the id of state
* @return the builder to build state on entry actions
*/
EntryExitActionBuilder onEntry(S stateId);
/**
* Define on exit actions for state
* @param stateId the id of state
* @return the builder to build state on exit actions
*/
EntryExitActionBuilder onExit(S stateId);
/**
* Create a new state machine instance
* @param initialStateId initial state id
* @return new state machine instance
*/
T newStateMachine(S initialStateId);
/**
* Create new state machine instance according to state machine definition
* @param initialStateId the id of state machine initial state
* @param extraParams other parameters for instantiate state machine
* @return new state machine
*/
T newStateMachine(S initialStateId, Object... extraParams);
/**
* Create new state machine instance according to state machine definition
* @param initialStateId the id of state machine initial state
* @param configuration configuration for state machine
* @param extraParams other parameters for instantiate state machine
* @return new state machine
*/
T newStateMachine(S initialStateId, StateMachineConfiguration configuration, Object... extraParams);
/**
* Set default state machine configuration for state machine instance created by this builder
* @param configure state machine default configuration
*/
void setStateMachineConfiguration(StateMachineConfiguration configure);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy