org.squirrelframework.foundation.fsm.ImmutableState 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.util.List;
import org.squirrelframework.foundation.component.SquirrelComponent;
/**
* State The basic unit that composes a state machine. A state machine can be in one state at
* any particular time.
* Entry Action An activity executed when entering the state
* Entry Action An activity executed when entering the state
* Final State A state which represents the completion of the state machine.
*
* @author Henry.He
*
* @param type of State Machine
* @param type of State
* @param type of Event
* @param type of Context
*/
public interface ImmutableState, S, E, C> extends Visitable, SquirrelComponent {
/**
* @return state id
*/
S getStateId();
/**
* @return whether state is root state
*/
boolean isRootState();
/**
* @return Activities executed when entering the state
*/
List> getEntryActions();
/**
* @return Activities executed when exiting the state
*/
List> getExitActions();
/**
* @return All transitions start from this state
*/
List> getAllTransitions();
/**
* @param event
* @return Transitions triggered by event
*/
List> getTransitions(E event);
/**
* Entry state with state context
* @param stateContext
*/
void entry(StateContext stateContext);
/**
* Enters this state by its history depending on its
* HistoryType
. The Entry
method has to be called
* already.
*
* @param stateContext
* the state context.
* @return the active state. (depends on this statesHistoryType
)
*/
ImmutableState enterByHistory(StateContext stateContext);
/**
* Enters this state is deep mode: mode if there is one.
*
* @param stateContext
* the event context.
* @return the active state.
*/
ImmutableState enterDeep(StateContext stateContext);
/**
* Enters this state is shallow mode: The entry action is executed and the
* initial state is entered in shallow mode if there is one.
* @param stateContext
* @return child state entered by shadow
*/
ImmutableState enterShallow(StateContext stateContext);
/**
* Exit state with state context
* @param stateContext
*/
void exit(StateContext stateContext);
/**
* @return parent state
*/
ImmutableState getParentState();
/**
* @return child states
*/
List> getChildStates();
/**
* @return whether state has child states
*/
boolean hasChildStates();
/**
* @return initial child state
*/
ImmutableState getInitialState();
/**
* Notify transitions when receiving event.
* @param stateContext
*/
void internalFire(StateContext stateContext);
/**
* @return whether current state is final state
*/
boolean isFinalState();
/**
* @return hierarchy state level
*/
int getLevel();
/**
* @return Historical type of state
*/
HistoryType getHistoryType();
/**
* @return child states composite type
*/
StateCompositeType getCompositeType();
/**
* @return whether child states composite type is parallel
*/
boolean isParallelState();
boolean isRegion();
/**
* Verify state correctness
*/
void verify();
ImmutableState getThis();
}