/** * Transition to next state * * @throws IllegalStateException if transition is not allowed * @throws NullPointerException if the {@code nextState} is {@code null} */ public StateMachine<T> next(T nextState) throws IllegalStateException { Set<T> allowed = transitions.get(currentState); checkNotNull(allowed, "No transitions from state " + currentState); checkState(allowed.contains(nextState), "Transition not allowed from state " + currentState + " to " + nextState); currentState = nextState; return this; }
/** * Transition to next state * * @throws IllegalStateException if transition is not allowed * @throws NullPointerException if the {@code nextState} is {@code null} */ public StateMachine<T> next(T nextState) throws IllegalStateException { Set<T> allowed = transitions.get(currentState); checkNotNull(allowed, "No transitions from state " + currentState); checkState(allowed.contains(nextState), "Transition not allowed from state " + currentState + " to " + nextState); currentState = nextState; return this; }