Package nl.tue.id.oocsi.client.behavior.state

# Class OOCSIStateMachine

java.lang.Object
nl.tue.id.oocsi.client.behavior.state.OOCSIStateMachine

    public class OOCSIStateMachine
    extends java.lang.Object

A simple finite state machine for use with OOCSI API and logic was inspired by the Processing StateMachine library: https://github.com/atduskgreg/Processing-FSM and the AlphaBeta FSM library for Arduino: http://www.arduino.cc/playground/Code/FiniteStateMachine

Author:
  matsfunk

- ## Nested Class Summary

  Nested Classes
  Modifier and Type | Class | Description
  --- | --- | ---
  `class` | `OOCSIStateMachine.State` | internal state representation
  `class` | `OOCSIStateMachine.Transition` | internal transition representation

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `OOCSIStateMachine()` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `OOCSIStateMachine.State` | `addState​(java.lang.String name, Handler enter, Handler execute, Handler exit)` | add a new state to the state machine by specifying its name, and optional handlers for this new state's enter and exit events, and the execute handler that will be used while state is on
  `void` | `addTransition​(OOCSIStateMachine.State source, OOCSIStateMachine.State destination)` | add a new transition between the source and the destination state
  `void` | `execute()` | triggers the execute handler of the current state of this state machine
  `java.lang.String` | `get()` | get the current state of this state machine; might be null
  `OOCSIStateMachine.State` | `get​(java.lang.String name)` | get the state with the given name
  `boolean` | `isInState​(java.lang.String state)` | check if this state machine is currently in the given state
  `void` | `set​(java.lang.String newState)` | set the state with the given name as the new current state; will trigger enter and exit handlers respectively

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

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

- ## Constructor Details

  - ### OOCSIStateMachine

    public OOCSIStateMachine()

- ## Method Details

  - ### addState

    public OOCSIStateMachine.State addState​(java.lang.String name, Handler enter, Handler execute, Handler exit)
    add a new state to the state machine by specifying its name, and optional handlers for this new state's enter and exit events, and the execute handler that will be used while state is on
    Parameters:
      `name` -
      `enter` -
      `execute` -
      `exit` -
    Returns:
      the new state

  - ### execute

    public void execute()
    triggers the execute handler of the current state of this state machine

  - ### isInState

    public boolean isInState​(java.lang.String state)
    check if this state machine is currently in the given state
    Parameters:
      `state` -
    Returns:

  - ### get

    public java.lang.String get()
    get the current state of this state machine; might be null
    Returns:

  - ### get

    public OOCSIStateMachine.State get​(java.lang.String name)
    get the state with the given name
    Parameters:
      `name` -
    Returns:

  - ### set

    public void set​(java.lang.String newState)
    set the state with the given name as the new current state; will trigger enter and exit handlers respectively
    Parameters:
      `newState` -

  - ### addTransition

    public void addTransition​(OOCSIStateMachine.State source, OOCSIStateMachine.State destination)
    add a new transition between the source and the destination state
    Parameters:
      `source` -
      `destination` -