Package org.apache.nemo.common
Class StateMachine.Builder
- java.lang.Object
-
- org.apache.nemo.common.StateMachine.Builder
-
- Enclosing class:
- StateMachine
public static final class StateMachine.Builder extends java.lang.Object
Builder that builds a StateMachine.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StateMachine.Builder
addState(java.lang.Enum stateEnum, java.lang.String description)
Adds a state with name and description.StateMachine.Builder
addTransition(java.lang.Enum from, java.lang.Enum to, java.lang.String description)
Adds a transition with description.StateMachine
build()
Builds and returns the StateMachine.StateMachine.Builder
setInitialState(java.lang.Enum stateToSet)
-
-
-
Method Detail
-
addState
public StateMachine.Builder addState(java.lang.Enum stateEnum, java.lang.String description)
Adds a state with name and description.- Parameters:
stateEnum
- enumeration indicating the statedescription
- description of the state- Returns:
- the builder
- Throws:
java.lang.RuntimeException
- if the state was already added
-
setInitialState
public StateMachine.Builder setInitialState(java.lang.Enum stateToSet)
- Parameters:
stateToSet
- the initial state for StateMachine- Returns:
- the builder
- Throws:
java.lang.RuntimeException
- if the initial state was not added first
-
addTransition
public StateMachine.Builder addTransition(java.lang.Enum from, java.lang.Enum to, java.lang.String description)
Adds a transition with description.- Parameters:
from
- from state nameto
- to state namedescription
- description of the transition- Returns:
- the builder
- Throws:
java.lang.RuntimeException
- if either from or to state was not added, or the same transition was already added
-
build
public StateMachine build()
Builds and returns the StateMachine.- Returns:
- the StateMachine
- Throws:
java.lang.RuntimeException
- if an initial state was not set
-
-