ilog.rules.teamserver.model.states

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

  • java.lang.Object
    • ilog.rules.teamserver.model.states.TransitionSystem<State>
  • Type Parameters:
    State - A Java enumeration.
    Direct Known Subclasses:
    TableTransitionSystem


    public abstract class TransitionSystem<State extends java.lang.Enum<State>>
    extends java.lang.Object

    Defines the possible transitions between states. This class provides classical accessibility queries on a state transition systems.

    Subclasses must implement the isInitialState(State) and isPossibleTransition(State, State) methods to specify the possible transitions. The following contract must be obeyed by these two methods:

    • A possible transition from a null state to a state s means that s is an initial state. As a consequence, the Boolean values of isInitialState(s) and of isPossibleTransition(null, s) must be the same.
    • A transition to a null state has no meaning. A NullPointerException must be thrown when null is passed to isInitialState(State) or as the second argument of isPossibleTransition(State, State).
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected TransitionSystem(java.lang.Class<State> stateClass)
      Constructs a transition system for the states in the State enumeration passed as a parameter to this class.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      int countNextStates(State s)
      Returns the number of successors of the provided state.
      int countPreviousStates(State s)
      Returns the number of predecessors of the provided state.
      java.util.Set<State> getAccessibleStates(State s)
      Returns the set of all states that can be reached from the provided state with one or more transitions.
      protected java.util.Set<State> getAccessibleStates(State s1, java.util.EnumSet<State> visited)
      Utility method that remembers the states visited, to avoid looping on loops.
      java.util.Set<State> getFinalStates()
      Returns the set of final states.
      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.
      java.util.Set<State> getPreviousStates(State s)
      Returns the set of all states from which a transition to the provided state is possible.
      java.util.Set<State> getSelfAccessibleStates()
      Returns the set of states for which a non-empty path to themselves exist.
      boolean isAccessible(State s1, State s2)
      Indicates whether there is a non-empty path between the provided states.
      protected boolean isAccessible(State s1, State s2, java.util.EnumSet<State> visited)
      Utility method that remembers the states visited, to avoid looping on loops.
      boolean isFinalState(State s)
      Indicates whether the provided state is final.
      abstract boolean isInitialState(State s)
      Indicates whether the provided state is an initial state.
      abstract boolean isPossibleTransition(State s1, State s2)
      Indicates whether the transition is allowed.
      • Methods inherited from class java.lang.Object

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

      • TransitionSystem

        protected TransitionSystem(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.

        Parameters:
        stateClass - The reflective object for the state enumeration.
    • Method Detail

      • isInitialState

        public abstract boolean isInitialState(State s)

        Indicates 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 TableTransitionSystem.addInitialStates(State...).

        Note: This method must return true iff isPossibleTransition(null, s) returns true.

        Throws:
        java.lang.NullPointerException - if s is null.
        Parameters:
        s - The state to test. Cannot be null.
        Returns:
        true if the provided state is an initial state.
      • isPossibleTransition

        public abstract boolean isPossibleTransition(State s1,
                                   State s2)

        Indicates 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.

        Throws:
        java.lang.NullPointerException - if s2 is null.
        Parameters:
        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.
        Returns:
        true if the transition is allowed.
        See Also:
        getNextStates(State)
      • getNextStates

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

        Returns 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.

        Parameters:
        s - The state whose successors are queried. If null, the initial states are returned.
        Returns:
        the states to which a transition from the s is possible. The initial states if s is null.
        See Also:
        countNextStates(State), isAccessible(State, State)
      • countNextStates

        public int countNextStates(State s)

        Returns the number of successors of the provided state.

        Parameters:
        s - The state whose successors are queried. If null, the number of initial states is returned.
        Returns:
        the number of successors of s.
        See Also:
        getNextStates(State)
      • getPreviousStates

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

        Returns the set of all states from which a transition to 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.

        Throws:
        java.lang.NullPointerException - if s is null.
        Parameters:
        s - The state whose predecessors are queried. Cannot be null.
        Returns:
        the set of predecessors of s.
      • countPreviousStates

        public int countPreviousStates(State s)

        Returns the number of predecessors of the provided state.

        Throws:
        java.lang.NullPointerException - if s is null.
        Parameters:
        s - The state whose predecessors are queried. Cannot be null.
        Returns:
        the number of predecessors of s.
        See Also:
        getPreviousStates(State)
      • isAccessible

        public boolean isAccessible(State s1,
                           State s2)

        Indicates whether there is a non-empty path between the provided states.

        Throws:
        java.lang.NullPointerException - if s2 is null.
        Parameters:
        s1 - The start state of the path.
        s2 - Then end state of the path. Cannot be null.
        Returns:
        true if s2 can be reached from s1 in one or more transitions.
        See Also:
        getAccessibleStates(State)
      • isAccessible

        protected boolean isAccessible(State s1,
                           State s2,
                           java.util.EnumSet<State> visited)
        Utility method that remembers the states visited, to avoid looping on loops.
      • getSelfAccessibleStates

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

        Returns the set of states for which a non-empty path to themselves exist.

        Returns:
        the set of states that are accessible from themselves.
        See Also:
        getAccessibleStates(State)
      • isFinalState

        public boolean isFinalState(State s)

        Indicates whether the provided state is final. A state is final if there exists no possible transition from this state to another.

        Throws:
        java.lang.NullPointerException - if s is null.
        Parameters:
        s - The state to check. Cannot be null.
        Returns:
        true if no transition from s is possible.
      • getFinalStates

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

        Returns the set of final states. A state is final if there exists no possible transition from this state to another.

        Returns:
        the set of states from which no transition is possible.
      • getAccessibleStates

        public java.util.Set<State> getAccessibleStates(State s)

        Returns the set of all states that can be reached from the provided state with one or more transitions. Empty paths are not counted, meaning that the provided state is included in the returned set only if there is a proper loop in the transition system.

        Parameters:
        s - The start state of the path.
        Returns:
        the states that can be reached from s with one or more transitions.
      • getAccessibleStates

        protected java.util.Set<State> getAccessibleStates(State s1,
                                               java.util.EnumSet<State> visited)
        Utility method that remembers the states visited, to avoid looping on loops.

© Copyright IBM Corp. 1987, 2017