public final class StateMachine extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StateMachine.Builder
Builder that builds a StateMachine.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkState(Enum expectedCurrentState)
Checks whether the current state is same as the
expectedCurrentState. |
boolean |
compareAndSetState(Enum expectedCurrentState,
Enum state)
Atomically sets the state to the given updated state
if the current state equals to the expected state.
|
Enum |
getCurrentState() |
static StateMachine.Builder |
newBuilder() |
void |
setState(Enum state)
Sets the current state as a certain state.
|
String |
toString() |
public void checkState(Enum expectedCurrentState)
expectedCurrentState.expectedCurrentState - the expected current stateRuntimeException - if the expectedCurrentState is not same as the actual current statepublic void setState(Enum state)
state - a stateRuntimeException - if the state is unknown state, or the transition
from the current state to the specified state is illegalpublic boolean compareAndSetState(Enum expectedCurrentState, Enum state)
expectedCurrentState - an expected statestate - a statetrue if successful. false indicates that
the actual value was not equal to the expected value.RuntimeException - if the state is unknown state, or the transition
from the current state to the specified state is illegalpublic Enum getCurrentState()
public static StateMachine.Builder newBuilder()
Copyright © 2018. All rights reserved.