Class AbstractStateMachine<S extends Enum>

    • Constructor Detail

      • AbstractStateMachine

        protected AbstractStateMachine​(S initialState)
        Creates a new state machine.
        Parameters:
        initialState - the initial state of the state machine.
    • Method Detail

      • states

        public final rx.Observable<S> states()
        Description copied from interface: Stateful
        Returns a infinite observable which gets updated when the state of the component changes.
        Specified by:
        states in interface Stateful<S extends Enum>
        Returns:
        a Observable updated with state transitions.
      • state

        public final S state()
        Description copied from interface: Stateful
        Returns the current state.
        Specified by:
        state in interface Stateful<S extends Enum>
        Returns:
        the current state.
      • isState

        public final boolean isState​(S state)
        Description copied from interface: Stateful
        Check if the given state is the same as the current one.
        Specified by:
        isState in interface Stateful<S extends Enum>
        Parameters:
        state - the stats to check against.
        Returns:
        true if it is the same, false otherwise.
      • hasSubscribers

        public boolean hasSubscribers()
        Description copied from interface: Stateful
        Returns true if there are subscribers observing the state stream.
        Specified by:
        hasSubscribers in interface Stateful<S extends Enum>
        Returns:
        true if at least one does, false otherwise.
      • transitionState

        protected void transitionState​(S newState)
        Transition into a new state. This method is intentionally not public, because the subclass should only be responsible for the actual transitions, the other components only react on those transitions eventually.
        Parameters:
        newState - the states to transition into.