ilog.rules.teamserver.model.states

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

  • Type Parameters:
    State - A Java enumeration.
    Direct Known Subclasses:
    ConditionalTransitionSystem


    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.

    • Field Detail

      • explicitInitialStates

        protected java.util.EnumSet<State extends java.lang.Enum<State>> explicitInitialStates

        The set of states that have been explicitly declared as initial.

        See Also:
        addInitialStates(State...)
      • possibleTransitions

        protected java.util.EnumMap<State extends java.lang.Enum<State>,java.util.EnumSet<State extends java.lang.Enum<State>>> possibleTransitions

        The table of transitions.

    • Constructor Detail

      • TableTransitionSystem

        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.

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

      • addInitialStates

        public TableTransitionSystem<State> addInitialStates(State... states)

        Declares the provided states as initial, even if they have predecessors in the transition system.

        Parameters:
        states - Zero or more states to be explicitly declared as initial.
        Returns:
        the current transition system, returned to allow chained calls.
      • addNextStates

        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.

        Throws:
        java.lang.NullPointerException - if any state provided is null.
        Parameters:
        source - The state for which successors are declared.
        destinations - Zero or more states to be added as successors of source.
        Returns:
        the current transition system, returned to allow chained calls.
      • isInitialState

        public boolean isInitialState(State s)
        Description copied from class: TransitionSystem

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

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

        Specified by:
        isInitialState in class TransitionSystem<State extends java.lang.Enum<State>>
        Parameters:
        s - The state to test. Cannot be null.
        Returns:
        true if the provided state is an initial state.
      • dirtyInitialStates

        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.

      • computeInitialStates

        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.

        Returns:
        the set of initial states.
      • isPossibleTransition

        public boolean isPossibleTransition(State s1,
                                   State s2)
        Description copied from class: TransitionSystem

        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.

        Specified by:
        isPossibleTransition in class TransitionSystem<State extends java.lang.Enum<State>>
        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:
        TransitionSystem.getNextStates(State)
      • transitionExists

        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.

        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.

© Copyright IBM Corp. 1987, 2017