com.hazelcast.util

## Class StateMachine<T extends Enum<T>>

- java.lang.Object
- - com.hazelcast.util.StateMachine<T>

- Type Parameters:
    `T` -

      public class StateMachine<T extends Enum<T>>
      extends Object

  Simple state machine using an Enum as possible states.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StateMachine(T initialState)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `is(T state, T... otherStates)` Check if current state is one of given states
    `StateMachine<T>` | `next(T nextState)` Transition to next state
    `void` | `nextOrStay(T nextState)` Transition to next state if not already there
    `static <T extends Enum<T>> StateMachine<T>` | `of(T initialState)`
    `String` | `toString()`
    `StateMachine<T>` | `withTransition(T from, T to, T... moreTo)` Add a valid transition from one state to one or more states

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### StateMachine

          public StateMachine(T initialState)

  - ### Method Detail

    - #### of

          public static <T extends Enum<T>> StateMachine<T> of(T initialState)

    - #### withTransition

          public StateMachine<T> withTransition(T from,
                                                T to,
                                                T... moreTo)

      Add a valid transition from one state to one or more states

    - #### next

          public StateMachine<T> next(T nextState)
                               throws IllegalStateException

      Transition to next state
      Throws:
        `IllegalStateException` - if transition is not allowed
        `NullPointerException` - if the `nextState` is `null`

    - #### nextOrStay

          public void nextOrStay(T nextState)

      Transition to next state if not already there
      Throws:
        `IllegalStateException` - if transition is not allowed
        `NullPointerException` - if the `nextState` is `null`

    - #### is

          public boolean is(T state,
                            T... otherStates)

      Check if current state is one of given states

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2019. All rights reserved.