Package at.jku.ssw.fp.sect05_4.dsl
Class StateModel<S extends Enum<S>>
- java.lang.Object
-
- at.jku.ssw.fp.sect05_4.dsl.StateModel<S>
-
- Type Parameters:
S
- the type of the states; must be an enumeration type
- All Implemented Interfaces:
Action
- Direct Known Subclasses:
LevelControl
public abstract class StateModel<S extends Enum<S>> extends Object implements Action
Base class for implementing state transition models. State transition models have a set of states and state transitions. Provides methods for implementing the DSL for state transitions models.- Author:
- Herbert Praehofer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
StateModel.State
Inner class for state objects.
-
Field Summary
Fields Modifier and Type Field Description protected StateModel.State
current
The current stateprivate Map<S,StateModel.State>
states
Map from state value to state objects
-
Constructor Summary
Constructors Modifier Constructor Description protected
StateModel(S[] states, S initial)
Constructor initializing the set of states and the initial state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exec()
Executes the model by executing the current state object.protected StateModel.State
inState(S s)
Tests if the given state is the current state.protected void
nextState(S s)
Sets the current state to the given state.
-
-
-
Field Detail
-
states
private Map<S extends Enum<S>,StateModel.State> states
Map from state value to state objects
-
current
protected StateModel.State current
The current state
-
-
Method Detail
-
inState
protected StateModel.State inState(S s)
Tests if the given state is the current state.- Parameters:
s
- the state to test if it is the current state- Returns:
true
if the state is the current state
-
nextState
protected void nextState(S s)
Sets the current state to the given state.- Parameters:
s
- the new current state
-
-