State - A Java enumeration.public class TableTransitionSystem<State extends java.lang.Enum<State>> extends TransitionSystem<State>
Defines a state transition system where the list of possible transitions is explicitly given by providing, for each state, the list of its successors. Transitions are unconditional, meaning that a transition is possible between two states iff the second state has been declared as a successor of the first one.
States that have not been declared as the successor of any other state are considered as initial states. Additional states can be explicitly
declared as initial with the addInitialStates(State...) method.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.EnumSet<State> |
explicitInitialStates
The set of states that have been explicitly declared as initial.
|
protected java.util.EnumSet<State> |
initialStates
The set of initial states, as computed by
computeInitialStates(). |
protected java.util.EnumMap<State,java.util.EnumSet<State>> |
possibleTransitions
The table of transitions.
|
stateClass| Constructor and Description |
|---|
TableTransitionSystem(java.lang.Class<State> stateClass)
Constructs a transition system for the states in the
State enumeration passed as a parameter to this class. |
| Modifier and Type | Method and Description |
|---|---|
TableTransitionSystem<State> |
addInitialStates(State... states)
Declares the provided states as initial, even if they have predecessors in the transition system.
|
TableTransitionSystem<State> |
addNextStates(State source,
State... destinations)
Declares the provided states as successors of the one provided first.
|
protected java.util.EnumSet<State> |
computeInitialStates()
Computes the set of initial states, as defined by
isInitialState(State). |
protected void |
dirtyInitialStates()
Marks the set of initial state as needing recomputation.
|
java.util.Set<State> |
getInitialStates()
Returns the set of initial states.
|
java.util.Set<State> |
getNextStates(State s)
Returns the set of all states to which a transition from the provided state is possible.
|
boolean |
isInitialState(State s)
Indicates whether the provided state is an initial state.
|
boolean |
isPossibleTransition(State s1,
State s2)
Indicates whether the transition is allowed.
|
protected boolean |
transitionExists(State s1,
State s2)
Indicates whether the checked transition is possible, based only on the table of successors declared in this class.
|
countNextStates, countPreviousStates, getAccessibleStates, getAccessibleStates, getFinalStates, getPreviousStates, getSelfAccessibleStates, isAccessible, isAccessible, isFinalStateprotected java.util.EnumSet<State extends java.lang.Enum<State>> initialStates
The set of initial states, as computed by computeInitialStates(). This field is null if the set of initial state has not
been computed yet, or may need recomputing.
computeInitialStates(),
dirtyInitialStates()protected java.util.EnumSet<State extends java.lang.Enum<State>> explicitInitialStates
The set of states that have been explicitly declared as initial.
addInitialStates(State...)public TableTransitionSystem(java.lang.Class<State> stateClass)
Constructs a transition system for the states in the State enumeration passed as a parameter to this class. Since type information
is not available at run-time for Java generic classes, the reflective Class object for the state enumeration has to be provided to the
constructor.
stateClass - The reflective object for the state enumeration.public TableTransitionSystem<State> addInitialStates(State... states)
Declares the provided states as initial, even if they have predecessors in the transition system.
states - Zero or more states to be explicitly declared as initial.public TableTransitionSystem<State> addNextStates(State source, State... destinations)
Declares the provided states as successors of the one provided first. As a result, transitions from the first to any other provided states are possible.
java.lang.NullPointerException - if any state provided is null.source - The state for which successors are declared.destinations - Zero or more states to be added as successors of source.public boolean isInitialState(State s)
TransitionSystemIndicates whether the provided state is an initial state. States that are not accessible from any other state are initial states; other states
can also be declared as initial by methods such as addInitialStates(State...).
Note: This method must return true iff isPossibleTransition(null, s) returns true.
isInitialState in class TransitionSystem<State extends java.lang.Enum<State>>s - The state to test. Cannot be null.true if the provided state is an initial state.public java.util.Set<State> getInitialStates()
TransitionSystemReturns the set of initial states. States that are not accessible from any other state are initial states; other states
can also be declared as initial by methods such as addInitialStates(State...).
getInitialStates in class TransitionSystem<State extends java.lang.Enum<State>>TransitionSystem.isInitialState(State)protected void dirtyInitialStates()
Marks the set of initial state as needing recomputation. This method must be called basically each time the table of transitions is modified.
protected java.util.EnumSet<State> computeInitialStates()
Computes the set of initial states, as defined by isInitialState(State). This method must be called before accessing initialStates
if this field is null.
public boolean isPossibleTransition(State s1, State s2)
TransitionSystemIndicates whether the transition is allowed. By extension, a possible transition from a null state means that the end state of the
transition is an initial state.
Note: If s1 is null, then this method must return true iff isInitialState(s2) returns
true.
isPossibleTransition in class TransitionSystem<State extends java.lang.Enum<State>>s1 - The start state of the transition, or null to check whether s2 is an initial state.s2 - Then end state of the transition. Cannot be null.true if the transition is allowed.TransitionSystem.getNextStates(State)protected final boolean transitionExists(State s1, State s2)
Indicates whether the checked transition is possible, based only on the table of successors declared in this class. As far as
TableTransitionSystem is concerned, this method is equivalent to isPossibleTransition(State, State). However, the latter is not final
whereas this method is. This method can thus be used to query the table of successors declared in this class, without the risk of taking
additional conditions in account.
java.lang.NullPointerException - if s2 is null.s1 - The start state of the transition, or null to check whether s2 is an initial state.s2 - Then end state of the transition. Cannot be null.true if the transition is allowed.public java.util.Set<State> getNextStates(State s)
TransitionSystemReturns the set of all states to which a transition from the provided state is possible. If no transition is possible, an empty set is returned. Do not modify the returned set; make a copy of it if needed.
getNextStates in class TransitionSystem<State extends java.lang.Enum<State>>s - The state whose successors are queried. If null, the initial states are returned.s is possible. The initial states if s is null.TransitionSystem.countNextStates(State),
TransitionSystem.isAccessible(State, State)© Copyright IBM Corp. 1987, 2017