Class StateMachine<T extends Enum>

java.lang.Object
org.antublue.test.engine.internal.util.StateMachine<T>
Type Parameters:
T - state type

public class StateMachine<T extends Enum> extends Object
Class to implement a StateMachine
  • Constructor Details

    • StateMachine

      public StateMachine(String name, T state)
      Constructor
      Parameters:
      name - name
  • Method Details

    • name

      public String name()
      Method to get the name
      Returns:
      the name
    • state

      public T state()
      Method to get the state
      Returns:
      the state
    • set

      public void set(T state)
      Method to set the state
      Parameters:
      state - the state
    • ifThen

      public boolean ifThen(T checkState, T nextState)
      Method to transition to a state if the current state matches
      Parameters:
      checkState - the state to check
      nextState - the next state
      Returns:
      true if the transition occurs, else false
    • ifNotThen

      public boolean ifNotThen(T checkState, T nextState)
      Method to transition to a state if the current state doesn't match
      Parameters:
      checkState - the state to check
      nextState - the next state
      Returns:
      true if the transition occurs, else false
    • ifTrueThenElse

      public void ifTrueThenElse(boolean value, T trueState, T falseState)
      Method to check a boolean. If true, transition to the first state, else transition to the second state
      Parameters:
      value - the value to check
      trueState - the next state if the value is true
      falseState - the next state if the value is false
    • toString

      public String toString()
      Overrides:
      toString in class Object