Package org.apache.mina.statemachine
Class State
- java.lang.Object
-
- org.apache.mina.statemachine.State
-
public class State extends java.lang.ObjectRepresents a state in aStateMachine. Normally you wouldn't create instances of this class directly but rather use theStateannotation to define your states and then letStateMachineFactorycreate aStateMachinefor you.States inheritsTransitions from their parent. AStatecan override any of the parentsTransitions. When anEventis processed theTransitions of the currentStatewill be searched for aTransitionwhich can handle the event. If none is found theState's parent will be searched and so on.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classState.TransitionHolder
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringidThe state IDprivate java.util.List<SelfTransition>onEntriesThe list of entry transitions on a stateprivate java.util.List<SelfTransition>onExitsThe list of exit transition from a stateprivate StateparentThe parent stateprivate java.util.List<State.TransitionHolder>transitionHoldersprivate java.util.List<Transition>transitionsThe list of transitions for this state
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) StateaddOnEntrySelfTransaction(SelfTransition onEntrySelfTransaction)Adds an entrySelfTransitionto thisState(package private) StateaddOnExitSelfTransaction(SelfTransition onExitSelfTransaction)Adds an exitSelfTransitionto thisStateStateaddTransition(Transition transition)Adds an outgoingTransitionto thisStatewith weight 0.StateaddTransition(Transition transition, int weight)Adds an outgoingTransitionto thisStatewith the specified weight.booleanequals(java.lang.Object o)java.lang.StringgetId()java.util.List<SelfTransition>getOnEntrySelfTransitions()java.util.List<SelfTransition>getOnExitSelfTransitions()StategetParent()java.util.List<Transition>getTransitions()inthashCode()java.lang.StringtoString()private voidupdateTransitions()
-
-
-
Field Detail
-
id
private final java.lang.String id
The state ID
-
parent
private final State parent
The parent state
-
transitionHolders
private java.util.List<State.TransitionHolder> transitionHolders
-
transitions
private java.util.List<Transition> transitions
The list of transitions for this state
-
onEntries
private java.util.List<SelfTransition> onEntries
The list of entry transitions on a state
-
onExits
private java.util.List<SelfTransition> onExits
The list of exit transition from a state
-
-
Method Detail
-
getId
public java.lang.String getId()
- Returns:
- the id of this
State.
-
getTransitions
public java.util.List<Transition> getTransitions()
- Returns:
- an unmodifiable
ListofTransitions going out from thisState.
-
getOnEntrySelfTransitions
public java.util.List<SelfTransition> getOnEntrySelfTransitions()
- Returns:
- an unmodifiable
Listof entrySelfTransitions
-
getOnExitSelfTransitions
public java.util.List<SelfTransition> getOnExitSelfTransitions()
- Returns:
- an unmodifiable
Listof exitSelfTransitions
-
addOnEntrySelfTransaction
State addOnEntrySelfTransaction(SelfTransition onEntrySelfTransaction)
Adds an entrySelfTransitionto thisState- Parameters:
selfTransition- theSelfTransitionto add.- Returns:
- this
State.
-
addOnExitSelfTransaction
State addOnExitSelfTransaction(SelfTransition onExitSelfTransaction)
Adds an exitSelfTransitionto thisState- Parameters:
selfTransition- theSelfTransitionto add.- Returns:
- this
State.
-
updateTransitions
private void updateTransitions()
-
addTransition
public State addTransition(Transition transition)
Adds an outgoingTransitionto thisStatewith weight 0.- Parameters:
transition- theTransitionto add.- Returns:
- this
State. - See Also:
addTransition(Transition, int)
-
addTransition
public State addTransition(Transition transition, int weight)
Adds an outgoingTransitionto thisStatewith the specified weight. The higher the weight the less important aTransitionis. If twoTransitions match the sameEventtheTransitionwith the lower weight will be executed.- Parameters:
transition- theTransitionto add.weight- The weight of this transition- Returns:
- this
State.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-