Class State


  • public class State
    extends NameBase
    Base class for all states in a StateEngine. This must be used as the base class for all states in transitions added to a StateEngine.
    • Field Detail

      • defaultAction

        private Action defaultAction
      • defaultNextState

        private State defaultNextState
      • inputMap

        private java.util.Map<Input,​java.util.Set<Transition>> inputMap
      • inputMapRangeImage

        private java.util.Map<Input,​java.util.Set<Transition>> inputMapRangeImage
      • inputMapImage

        private java.util.Map<Input,​java.util.Set<Transition>> inputMapImage
    • Constructor Detail

      • State

        public State​(java.lang.String name)
      • State

        public State​(java.lang.String name,
                     State.Kind kind)
      • State

        public State​(java.util.Set<State> states,
                     java.lang.String name)
      • State

        public State​(java.util.Set<State> states,
                     java.lang.String name,
                     State.Kind kind)
    • Method Detail

      • getKind

        public State.Kind getKind()
        Return the Kind of this state.
      • preAction

        public FSM preAction​(FSM fsm)
        Method that defines action that occurs whenever this state is entered from a different state. preAction is not called on a self-transition. If preAction returns a non-null result, the result becomes the current FSM.

        Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.

      • returnAction

        public State returnAction​(FSM fsm,
                                  FSM nestedFSM)
        If this state has Kind REFERENCE, and its preAction pushes a nested FSM onto the stack, the returnAction method is called after the nested FSM reaches a final state. The nested FSM is passed into nestedFSM, and fsm is the new top of stack, which is the FSM that was active when the preAction was called. The result is the new state that will be assumed after this REFERENCE's state postAction method is called.

        If the returnAction method sets the state to a new state, the postAction method is called as usuTransition.

        Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.

      • postAction

        public void postAction​(FSM fsm)
        Method that defines action that occurs whenever this state is exited, that is, when the state is changed from this state to a new state.

        Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.

      • getDefaultNextState

        public State getDefaultNextState()
        Return the default next state for this state. This is the next state if the input is not found in the action map.
      • getDefaultAction

        public Action getDefaultAction()
        Get the default transition action that is used if the default next state is used.
      • getInputMap

        public java.util.Map<Input,​java.util.Set<Transition>> getInputMap()
      • setDefaultNextState

        void setDefaultNextState​(State defaultNextState)
      • setDefaultAction

        void setDefaultAction​(Action defaultAction)