Class AbstractHandlerWithState

    • Constructor Detail

      • AbstractHandlerWithState

        public AbstractHandlerWithState()
    • Method Detail

      • addState

        public void addState​(String stateId,
                             State state)

        Adds a state to this handler. This will add this handler as a listener to the state, and then fire a handleStateChange so that the handler can respond to the incoming state.

        Clients may extend this method, but they should call this super method first before doing anything else.

        Specified by:
        addState in interface IObjectWithState
        Parameters:
        stateId - The identifier indicating the type of state being added; must not be null.
        state - The state to add; must not be null.
      • getState

        public final State getState​(String stateId)
        Description copied from interface: IObjectWithState
        Gets the state with the given id.
        Specified by:
        getState in interface IObjectWithState
        Parameters:
        stateId - The identifier of the state to retrieve; must not be null.
        Returns:
        The state; may be null if there is no state with the given id.
      • getStateIds

        public final String[] getStateIds()
        Description copied from interface: IObjectWithState
        Gets the identifiers for all of the state associated with this object.
        Specified by:
        getStateIds in interface IObjectWithState
        Returns:
        All of the state identifiers; may be empty, but never null.
      • removeState

        public void removeState​(String stateId)

        Removes a state from this handler. This will remove this handler as a listener to the state. No event is fired to notify the handler of this change.

        Clients may extend this method, but they should call this super method first before doing anything else.

        Specified by:
        removeState in interface IObjectWithState
        Parameters:
        stateId - The identifier of the state to remove; must not be null.