State - A Java enumeration.public class ControlledState<State extends java.lang.Enum<State>>
extends java.lang.Object
Stores a state that can only evolve as defined by a companion transition system. An instance of this class stores a value of the Java enumeration that implements the state. This value can be changed, but only with a value to which the transition system allows a transition from the current value.
IllegalTransitionException| Constructor and Description |
|---|
ControlledState(State initialState,
TransitionSystem<State> transitionSystem)
Constructs a state controlled by the provided transition system, and sets the provided value as the initial value of the state.
|
ControlledState(TransitionSystem<State> transitionSystem)
Constructs a state controlled by the provided transition system.
|
| Modifier and Type | Method and Description |
|---|---|
int |
countNextStates()
Returns the number of states to which the transition system allows a transition from the current state.
|
int |
countPreviousStates()
Returns the number of states from which the transition system allows a transition to the current state.
|
State |
get()
Returns the current value of the state.
|
java.util.Set<State> |
getAccessibleStates()
Return the set of all states that can be accessed from the current state through one or more transition in the transition system.
|
java.util.Set<State> |
getFinalStates()
Returns the set of final states, that is, the states from which no transition can be made.
|
java.util.Set<State> |
getInitialStates()
Returns the set of initial states as defined by
TransitionSystem.isInitialState(State). |
java.util.Set<State> |
getNextStates()
Returns the set of all states to which the transition system allows a transition from the current state.
|
java.util.Set<State> |
getPreviousStates()
Returns the set of all states from which the transition system allows a transition to the current state.
|
java.util.Set<State> |
getSelfAccessibleStates()
Return the set of all states that can be accessed from themselves through one or more transition in the transition system.
|
TransitionCondition<State> |
impossibleTransitionCause(State toState)
If the transition system uses transition conditions, returns the condition that fails, and hence makes the transition to the provided
state impossible.
|
boolean |
is(State state)
Indicates whether this state has the provided value.
|
boolean |
isAccessible(State toState)
Indicates whether the provided state can be accessed from the current state through one or more transition in the transition system.
|
boolean |
isFinal()
Indicates whether the current state is a final state in the transition system, that is, the transition system allows no transition from
the current state to any other state.
|
boolean |
isInitial()
Indicates whether the current state is an initial state in the transition system, as defined by
TransitionSystem.isInitialState(State). |
boolean |
isPossibleTransition(State toState)
Indicates whether the transition systems allows a transition from the current state to the provided one.
|
void |
set(State state)
Sets the state to the provided value.
|
public ControlledState(TransitionSystem<State> transitionSystem)
Constructs a state controlled by the provided transition system. No initial value is given to the state.
transitionSystem - The transition system that defines the possible transitions between state values. Cannot be null.public ControlledState(State initialState, TransitionSystem<State> transitionSystem) throws IllegalTransitionException
Constructs a state controlled by the provided transition system, and sets the provided value as the initial value of the state.
IllegalTransitionException - if initialState is not an initial state in the sense of TransitionSystem.isInitialState(State).initialState - The state to use as the initial value. Can be null; otherwise, must be an initial state in
transitionSystem.transitionSystem - The transition system that defines the possible transitions between state values. Cannot be null.public State get()
Returns the current value of the state.
public void set(State state) throws IllegalTransitionException
Sets the state to the provided value. The value must be a state to which a transition is allowed from the current state. If the current state
is null, the provided value must be an initial state in the transition system.
IllegalTransitionException - if the transition system does not allow a transition to the current state to the provided value.state - The new value of the state.isPossibleTransition(State)public boolean is(State state)
Indicates whether this state has the provided value.
state - The value to be tested against the current state.true if the state is state. Can be null.public boolean isInitial()
Indicates whether the current state is an initial state in the transition system, as defined by TransitionSystem.isInitialState(State).
java.lang.NullPointerException - if the current state is null.true if the current state is an initial state.public boolean isPossibleTransition(State toState)
Indicates whether the transition systems allows a transition from the current state to the provided one.
java.lang.NullPointerException - if toState is null.toState - The candidate state.true if a transition to toState is allowed.TransitionSystem.isPossibleTransition(State, State)public java.util.Set<State> getNextStates()
Returns the set of all states to which the transition system allows a transition from the current state.
TransitionSystem.getNextStates(State)public int countNextStates()
Returns the number of states to which the transition system allows a transition from the current state.
TransitionSystem.countNextStates(State)public java.util.Set<State> getPreviousStates()
Returns the set of all states from which the transition system allows a transition to the current state.
java.lang.NullPointerException - if the current state is null.TransitionSystem.getPreviousStates(State)public int countPreviousStates()
Returns the number of states from which the transition system allows a transition to the current state.
java.lang.NullPointerException - if the current state is null.TransitionSystem.countPreviousStates(State)public boolean isAccessible(State toState)
Indicates whether the provided state can be accessed from the current state through one or more transition in the transition system.
toState - The target state.true if there is a non-empty path from the current state to toState.TransitionSystem.isAccessible(State, State)public java.util.Set<State> getAccessibleStates()
Return the set of all states that can be accessed from the current state through one or more transition in the transition system.
TransitionSystem.getAccessibleStates(State)public java.util.Set<State> getSelfAccessibleStates()
Return the set of all states that can be accessed from themselves through one or more transition in the transition system. The result of this method does not depend on the current state.
TransitionSystem.getSelfAccessibleStates()public java.util.Set<State> getInitialStates()
Returns the set of initial states as defined by TransitionSystem.isInitialState(State). The result of
this method does not depend on the current state.
TransitionSystem.getInitialStates()public boolean isFinal()
Indicates whether the current state is a final state in the transition system, that is, the transition system allows no transition from the current state to any other state.
true if the current state has no successor.TransitionSystem.isFinalState(State)public java.util.Set<State> getFinalStates()
Returns the set of final states, that is, the states from which no transition can be made. The result of this method does not depend on the current state.
TransitionSystem.getFinalStates()public TransitionCondition<State> impossibleTransitionCause(State toState)
If the transition system uses transition conditions, returns the condition that fails, and hence makes the transition to the provided state impossible. An exception is thrown if the transition system does not use transition conditions.
Note: This method assumes that the transition to the provided state is indeed impossible. It does not test it. Unspecified result is returned if this method is called on a possible transition.
java.lang.NullPointerException - if toState is null.java.lang.UnsupportedOperationException - if the transition system is not an instance of ConditionalTransitionSystem.toState - The target state. Cannot be null.TransitionCondition that is not satisfied, which causes the transition to the provided state to be impossible.© Copyright IBM Corp. 1987, 2017