Class StateMachine<T extends Enum<T>>
- java.lang.Object
-
- com.couchbase.lite.internal.utils.StateMachine<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StateMachine.Builder<S extends Enum<S>>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
assertState(T... expected)
Verify expected state.boolean
setState(T nextState)
Set the new state.String
toString()
-
-
-
Method Detail
-
assertState
@SafeVarargs public final boolean assertState(@NonNull T... expected)
Verify expected state.- Parameters:
expected
- expected states.- Returns:
- true if the current state at the time of the call, is one of the expected states.
-
setState
public boolean setState(@NonNull T nextState)
Set the new state. If it is legal to transition to the new state, from the current state, do so, returning the now-previous state. If the transition is illegal do nothing and return null.- Parameters:
nextState
- the requested new state- Returns:
- the previous state, if the transition succeeds; null otherwise.
-
-