ilog.rules.teamserver.model.states

Class ControlledState<State extends java.lang.Enum<State>>

  • java.lang.Object
    • ilog.rules.teamserver.model.states.ControlledState<State>
  • Type Parameters:
    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.

    See Also:
    IllegalTransitionException
    • Constructor Summary

      Constructors 
      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.
    • Method Summary

      Methods 
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ControlledState

        public ControlledState(TransitionSystem<State> transitionSystem)

        Constructs a state controlled by the provided transition system. No initial value is given to the state.

        Parameters:
        transitionSystem - The transition system that defines the possible transitions between state values. Cannot be null.
      • ControlledState

        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.

        Throws:
        IllegalTransitionException - if initialState is not an initial state in the sense of TransitionSystem.isInitialState(State).
        Parameters:
        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.
    • Method Detail

      • get

        public State get()

        Returns the current value of the state.

        Returns:
        the current state.
      • set

        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.

        Throws:
        IllegalTransitionException - if the transition system does not allow a transition to the current state to the provided value.
        Parameters:
        state - The new value of the state.
        See Also:
        isPossibleTransition(State)
      • is

        public boolean is(State state)

        Indicates whether this state has the provided value.

        Parameters:
        state - The value to be tested against the current state.
        Returns:
        true if the state is state. Can be null.
      • isInitial

        public boolean isInitial()

        Indicates whether the current state is an initial state in the transition system, as defined by TransitionSystem.isInitialState(State).

        Throws:
        java.lang.NullPointerException - if the current state is null.
        Returns:
        true if the current state is an initial state.
      • isPossibleTransition

        public boolean isPossibleTransition(State toState)

        Indicates whether the transition systems allows a transition from the current state to the provided one.

        Throws:
        java.lang.NullPointerException - if toState is null.
        Parameters:
        toState - The candidate state.
        Returns:
        true if a transition to toState is allowed.
        See Also:
        TransitionSystem.isPossibleTransition(State, State)
      • getNextStates

        public java.util.Set<State> getNextStates()

        Returns the set of all states to which the transition system allows a transition from the current state.

        Returns:
        the successors of the current state.
        See Also:
        TransitionSystem.getNextStates(State)
      • countNextStates

        public int countNextStates()

        Returns the number of states to which the transition system allows a transition from the current state.

        Returns:
        the number of successors of the current state.
        See Also:
        TransitionSystem.countNextStates(State)
      • getPreviousStates

        public java.util.Set<State> getPreviousStates()

        Returns the set of all states from which the transition system allows a transition to the current state.

        Throws:
        java.lang.NullPointerException - if the current state is null.
        Returns:
        the predecessors of the current state.
        See Also:
        TransitionSystem.getPreviousStates(State)
      • countPreviousStates

        public int countPreviousStates()

        Returns the number of states from which the transition system allows a transition to the current state.

        Throws:
        java.lang.NullPointerException - if the current state is null.
        Returns:
        the number of predecessors of the current state.
        See Also:
        TransitionSystem.countPreviousStates(State)
      • isAccessible

        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.

        Parameters:
        toState - The target state.
        Returns:
        true if there is a non-empty path from the current state to toState.
        See Also:
        TransitionSystem.isAccessible(State, State)
      • getAccessibleStates

        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.

        Returns:
        the direct or indirect successors of the current state.
        See Also:
        TransitionSystem.getAccessibleStates(State)
      • getSelfAccessibleStates

        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.

        Returns:
        the states in proper loops.
        See Also:
        TransitionSystem.getSelfAccessibleStates()
      • isFinal

        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.

        Returns:
        true if the current state has no successor.
        See Also:
        TransitionSystem.isFinalState(State)
      • getFinalStates

        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.

        Returns:
        the states with no successors.
        See Also:
        TransitionSystem.getFinalStates()
      • impossibleTransitionCause

        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.

        Throws:
        java.lang.NullPointerException - if toState is null.
        java.lang.UnsupportedOperationException - if the transition system is not an instance of ConditionalTransitionSystem.
        Parameters:
        toState - The target state. Cannot be null.
        Returns:
        an instance of TransitionCondition that is not satisfied, which causes the transition to the provided state to be impossible.

© Copyright IBM Corp. 1987, 2017