org.squirrelframework.foundation.fsm
Interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

Type Parameters:
T - The type of implemented state machine
S - The type of implemented state
E - The type of implemented event
C - The type of implemented context
All Known Subinterfaces:
UntypedStateMachineBuilder
All Known Implementing Classes:
StateMachineBuilderImpl

public interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

State machine builder API.

Author:
Henry.He

Method Summary
 MutableState<T,S,E,C> defineFinalState(S stateId)
          Define a final state in state machine model
 void defineFinishEvent(E finishEvent)
          Define event for parallel transition finished
 MutableState<T,S,E,C> defineLinkedState(S stateId, StateMachineBuilder<? extends StateMachine<?,S,E,C>,S,E,C> linkedStateMachineBuilder, S initialLinkedState, Object... extraParams)
          Define a linked state
 void defineParallelStatesOn(S parentStateId, S... childStateIds)
          Define sequential child states on parent state.
 void defineSequentialStatesOn(S parentStateId, HistoryType historyType, S... childStateIds)
          Define sequential child states on parent state
 void defineSequentialStatesOn(S parentStateId, S... childStateIds)
          Define sequential child states whose hierarchy type is default set to NONE on parent state
 void defineStartEvent(E startEvent)
          Define event for state machine started
 MutableState<T,S,E,C> defineState(S stateId)
          Define a new state in state machine model
 void defineTerminateEvent(E terminateEvent)
          Define event for state machine terminated
 MutableState<T,S,E,C> defineTimedState(S stateId, long initialDelay, long timeInterval, E autoEvent, C autoContext)
          Define a timed state
 ExternalTransitionBuilder<T,S,E,C> externalTransition()
          Start to build external transition
 ExternalTransitionBuilder<T,S,E,C> externalTransition(int priority)
           
 InternalTransitionBuilder<T,S,E,C> internalTransition()
          Start to build internal transition
 InternalTransitionBuilder<T,S,E,C> internalTransition(int priority)
           
 LocalTransitionBuilder<T,S,E,C> localTransition()
          Start to build local transition
 LocalTransitionBuilder<T,S,E,C> localTransition(int priority)
           
 T newStateMachine(S initialStateId)
          Create a new state machine instance
 T newStateMachine(S initialStateId, Object... extraParams)
          Create new state machine instance according to state machine definition
 T newStateMachine(S initialStateId, StateMachineConfiguration configuration, Object... extraParams)
          Create new state machine instance according to state machine definition
 EntryExitActionBuilder<T,S,E,C> onEntry(S stateId)
          Define on entry actions for state
 EntryExitActionBuilder<T,S,E,C> onExit(S stateId)
          Define on exit actions for state
 void setStateMachineConfiguration(StateMachineConfiguration configure)
          Set default state machine configuration for state machine instance created by this builder
 DeferBoundActionBuilder<T,S,E,C> transit()
           
 ExternalTransitionBuilder<T,S,E,C> transition()
          Start to build external transition, same as externalTransition
 ExternalTransitionBuilder<T,S,E,C> transition(int priority)
          Same as externalTransition
 

Method Detail

externalTransition

ExternalTransitionBuilder<T,S,E,C> externalTransition()
Start to build external transition

Returns:
External transition builder

transition

ExternalTransitionBuilder<T,S,E,C> transition()
Start to build external transition, same as externalTransition

Returns:
External transition builder

transit

DeferBoundActionBuilder<T,S,E,C> transit()

localTransition

LocalTransitionBuilder<T,S,E,C> localTransition()
Start to build local transition

Returns:
Local transition builder

internalTransition

InternalTransitionBuilder<T,S,E,C> internalTransition()
Start to build internal transition

Returns:
Internal transition builder

externalTransition

ExternalTransitionBuilder<T,S,E,C> externalTransition(int priority)

transition

ExternalTransitionBuilder<T,S,E,C> transition(int priority)
Same as externalTransition

Parameters:
priority - transition priority
Returns:
External transition builder

localTransition

LocalTransitionBuilder<T,S,E,C> localTransition(int priority)

internalTransition

InternalTransitionBuilder<T,S,E,C> internalTransition(int priority)

defineState

MutableState<T,S,E,C> defineState(S stateId)
Define a new state in state machine model

Parameters:
stateId - id of new state
Returns:
defined new mutable state

defineFinalState

MutableState<T,S,E,C> defineFinalState(S stateId)
Define a final state in state machine model

Parameters:
stateId - id of final state
Returns:
defined final state

defineLinkedState

MutableState<T,S,E,C> defineLinkedState(S stateId,
                                        StateMachineBuilder<? extends StateMachine<?,S,E,C>,S,E,C> linkedStateMachineBuilder,
                                        S initialLinkedState,
                                        Object... extraParams)
Define a linked state

Parameters:
stateId - id of linked state
linkedStateMachineBuilder - linked state machine builder
initialLinkedState - initial linked state
extraParams - additional parameters used to create linked state machine
Returns:
linked state

defineTimedState

MutableState<T,S,E,C> defineTimedState(S stateId,
                                       long initialDelay,
                                       long timeInterval,
                                       E autoEvent,
                                       C autoContext)
Define a timed state

Parameters:
stateId - state id
initialDelay - initial delay ms
timeInterval - time period if null not repeat
autoEvent -
autoContext -
Returns:
timed state

defineSequentialStatesOn

void defineSequentialStatesOn(S parentStateId,
                              S... childStateIds)
Define sequential child states whose hierarchy type is default set to NONE on parent state

Parameters:
parentStateId - id of parent state
childStateIds - child states id of parent state. The first child state will be used as initial child state of parent state.

defineSequentialStatesOn

void defineSequentialStatesOn(S parentStateId,
                              HistoryType historyType,
                              S... childStateIds)
Define sequential child states on parent state

Parameters:
parentStateId - id of parent state
historyType - history type of parent state
childStateIds - child states id of parent state. The first child state will be used as initial child state of parent state.

defineParallelStatesOn

void defineParallelStatesOn(S parentStateId,
                            S... childStateIds)
Define sequential child states on parent state. For parallel state the history type always be none.

Parameters:
parentStateId - id of parent state
childStateIds - child states id of parent state. The first child state will be used as initial child state of parent state.

defineFinishEvent

void defineFinishEvent(E finishEvent)
Define event for parallel transition finished

Parameters:
finishEvent -

defineStartEvent

void defineStartEvent(E startEvent)
Define event for state machine started

Parameters:
startEvent -

defineTerminateEvent

void defineTerminateEvent(E terminateEvent)
Define event for state machine terminated

Parameters:
terminateEvent -

onEntry

EntryExitActionBuilder<T,S,E,C> onEntry(S stateId)
Define on entry actions for state

Parameters:
stateId - the id of state
Returns:
the builder to build state on entry actions

onExit

EntryExitActionBuilder<T,S,E,C> onExit(S stateId)
Define on exit actions for state

Parameters:
stateId - the id of state
Returns:
the builder to build state on exit actions

newStateMachine

T newStateMachine(S initialStateId)
Create a new state machine instance

Parameters:
initialStateId - initial state id
Returns:
new state machine instance

newStateMachine

T newStateMachine(S initialStateId,
                  Object... extraParams)
Create new state machine instance according to state machine definition

Parameters:
initialStateId - the id of state machine initial state
extraParams - other parameters for instantiate state machine
Returns:
new state machine

newStateMachine

T newStateMachine(S initialStateId,
                  StateMachineConfiguration configuration,
                  Object... extraParams)
Create new state machine instance according to state machine definition

Parameters:
initialStateId - the id of state machine initial state
configuration - configuration for state machine
extraParams - other parameters for instantiate state machine
Returns:
new state machine

setStateMachineConfiguration

void setStateMachineConfiguration(StateMachineConfiguration configure)
Set default state machine configuration for state machine instance created by this builder

Parameters:
configure - state machine default configuration


Copyright © 2013-2014. All Rights Reserved.