S - state typepublic static final class StateMachine.Builder<S> extends Object
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
StateMachine<S> |
build()
Builds a new state-machine with on the configuration provided to this builder.
|
StateMachine.Builder<S> |
initialState(S initialState)
Sets the state that the state-machine should start in.
|
<E> StateMachine.Builder<S> |
onInappropriateEvent(BiFunction<S,E,S> mapper)
Determines how to handle an inappropriate event.
|
StateMachine.Builder<S> |
onStateChange(StateChangeListener<S> stateChangeListener)
Add state-change-listener to be informed about state changes, including due to inappropriate events.
|
<E> StateMachine.Builder<S> |
transition(S state,
Class<E> eventClass,
Function<E,S> mapper)
Associates a state and event type with a function that returns a new state and possibly side-effects.
|
public StateMachine.Builder<S> initialState(S initialState)
initialState - initial statepublic <E> StateMachine.Builder<S> transition(S state, Class<E> eventClass, Function<E,S> mapper)
E - event typestate - state to transition fromeventClass - event classmapper - function that returns the new statepublic <E> StateMachine.Builder<S> onInappropriateEvent(BiFunction<S,E,S> mapper)
E - event typemapper - function that returns the new statepublic StateMachine.Builder<S> onStateChange(StateChangeListener<S> stateChangeListener)
stateChangeListener - state-change-listenerpublic StateMachine<S> build()
Copyright © 2013–2018 Hotels.com. All rights reserved.