org.squirrelframework.foundation.fsm.impl
Class StateMachineBuilderImpl<T extends StateMachine<T,S,E,C>,S,E,C>

java.lang.Object
  extended by org.squirrelframework.foundation.fsm.impl.StateMachineBuilderImpl<T,S,E,C>
All Implemented Interfaces:
StateMachineBuilder<T,S,E,C>

public class StateMachineBuilderImpl<T extends StateMachine<T,S,E,C>,S,E,C>
extends Object
implements StateMachineBuilder<T,S,E,C>


Field Summary
protected  Converter<E> eventConverter
           
protected  Converter<S> stateConverter
           
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stateConverter

protected final Converter<S> stateConverter

eventConverter

protected final Converter<E> eventConverter
Method Detail

externalTransition

public ExternalTransitionBuilder<T,S,E,C> externalTransition()
Description copied from interface: StateMachineBuilder
Start to build external transition

Specified by:
externalTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
External transition builder

transition

public ExternalTransitionBuilder<T,S,E,C> transition()
Description copied from interface: StateMachineBuilder
Start to build external transition, same as externalTransition

Specified by:
transition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
External transition builder

transit

public DeferBoundActionBuilder<T,S,E,C> transit()
Specified by:
transit in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

localTransition

public LocalTransitionBuilder<T,S,E,C> localTransition()
Description copied from interface: StateMachineBuilder
Start to build local transition

Specified by:
localTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Local transition builder

internalTransition

public InternalTransitionBuilder<T,S,E,C> internalTransition()
Description copied from interface: StateMachineBuilder
Start to build internal transition

Specified by:
internalTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Internal transition builder

externalTransition

public ExternalTransitionBuilder<T,S,E,C> externalTransition(int priority)
Specified by:
externalTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

transition

public ExternalTransitionBuilder<T,S,E,C> transition(int priority)
Description copied from interface: StateMachineBuilder
Same as externalTransition

Specified by:
transition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
priority - transition priority
Returns:
External transition builder

localTransition

public LocalTransitionBuilder<T,S,E,C> localTransition(int priority)
Specified by:
localTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

internalTransition

public InternalTransitionBuilder<T,S,E,C> internalTransition(int priority)
Specified by:
internalTransition in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

newStateMachine

public T newStateMachine(S initialStateId)
Description copied from interface: StateMachineBuilder
Create a new state machine instance

Specified by:
newStateMachine in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
initialStateId - initial state id
Returns:
new state machine instance

newStateMachine

public T newStateMachine(S initialStateId,
                         Object... extraParams)
Description copied from interface: StateMachineBuilder
Create new state machine instance according to state machine definition

Specified by:
newStateMachine in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
initialStateId - the id of state machine initial state
extraParams - other parameters for instantiate state machine
Returns:
new state machine

newStateMachine

public T newStateMachine(S initialStateId,
                         StateMachineConfiguration configuration,
                         Object... extraParams)
Description copied from interface: StateMachineBuilder
Create new state machine instance according to state machine definition

Specified by:
newStateMachine in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
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

defineState

public MutableState<T,S,E,C> defineState(S stateId)
Description copied from interface: StateMachineBuilder
Define a new state in state machine model

Specified by:
defineState in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateId - id of new state
Returns:
defined new mutable state

defineFinalState

public MutableState<T,S,E,C> defineFinalState(S stateId)
Description copied from interface: StateMachineBuilder
Define a final state in state machine model

Specified by:
defineFinalState in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateId - id of final state
Returns:
defined final state

defineLinkedState

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

Specified by:
defineLinkedState in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
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

public MutableState<T,S,E,C> defineTimedState(S stateId,
                                              long initialDelay,
                                              long timeInterval,
                                              E autoEvent,
                                              C autoContext)
Description copied from interface: StateMachineBuilder
Define a timed state

Specified by:
defineTimedState in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateId - state id
initialDelay - initial delay ms
timeInterval - time period if null not repeat
Returns:
timed state

defineSequentialStatesOn

public void defineSequentialStatesOn(S parentStateId,
                                     S... childStateIds)
Description copied from interface: StateMachineBuilder
Define sequential child states whose hierarchy type is default set to NONE on parent state

Specified by:
defineSequentialStatesOn in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
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

public void defineSequentialStatesOn(S parentStateId,
                                     HistoryType historyType,
                                     S... childStateIds)
Description copied from interface: StateMachineBuilder
Define sequential child states on parent state

Specified by:
defineSequentialStatesOn in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
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

public void defineParallelStatesOn(S parentStateId,
                                   S... childStateIds)
Description copied from interface: StateMachineBuilder
Define sequential child states on parent state. For parallel state the history type always be none.

Specified by:
defineParallelStatesOn in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
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.

onEntry

public EntryExitActionBuilder<T,S,E,C> onEntry(S stateId)
Description copied from interface: StateMachineBuilder
Define on entry actions for state

Specified by:
onEntry in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateId - the id of state
Returns:
the builder to build state on entry actions

onExit

public EntryExitActionBuilder<T,S,E,C> onExit(S stateId)
Description copied from interface: StateMachineBuilder
Define on exit actions for state

Specified by:
onExit in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateId - the id of state
Returns:
the builder to build state on exit actions

defineFinishEvent

public void defineFinishEvent(E finishEvent)
Description copied from interface: StateMachineBuilder
Define event for parallel transition finished

Specified by:
defineFinishEvent in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

defineStartEvent

public void defineStartEvent(E startEvent)
Description copied from interface: StateMachineBuilder
Define event for state machine started

Specified by:
defineStartEvent in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

defineTerminateEvent

public void defineTerminateEvent(E terminateEvent)
Description copied from interface: StateMachineBuilder
Define event for state machine terminated

Specified by:
defineTerminateEvent in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>

setStateMachineConfiguration

public void setStateMachineConfiguration(StateMachineConfiguration configure)
Description copied from interface: StateMachineBuilder
Set default state machine configuration for state machine instance created by this builder

Specified by:
setStateMachineConfiguration in interface StateMachineBuilder<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
configure - state machine default configuration


Copyright © 2013-2014. All Rights Reserved.