Class RuntimeState

java.lang.Object
com.nt.udc.util.state.RuntimeState

public class RuntimeState extends Object
This class maintains the state of a given Object from a set of pre-defined states.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs the RuntimeState in UNKNOWN state.
    RuntimeState(State initState)
    Constructs the RuntimeState in the given state.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(State compareState)
    Used to compare this RuntimeState Object with a State Object.
    Returns the state of the Object.
    void
    setState(State newState)
    Sets the state of the Object.
    Returns the String representation of the current state.
    void
    waitUntil(State waitState)
    Causes the current Thread to wait until the current state equals the "waitState".
    void
    waitWhile(State waitState)
    Causes the current Thread to wait while the current state equals the "waitState".

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RuntimeState

      public RuntimeState()
      Constructs the RuntimeState in UNKNOWN state.
    • RuntimeState

      public RuntimeState(State initState)
      Constructs the RuntimeState in the given state.
      Parameters:
      initState - Initial state of the Object.
  • Method Details

    • setState

      public void setState(State newState)
      Sets the state of the Object.
      Parameters:
      newState - New Object State
    • getState

      public State getState()
      Returns the state of the Object.
      Returns:
      State of the Object
    • equals

      public boolean equals(State compareState)
      Used to compare this RuntimeState Object with a State Object.
      Parameters:
      compareState - State to check for equality.
      Returns:
      true, if states are equal
    • waitUntil

      public void waitUntil(State waitState) throws InterruptedException
      Causes the current Thread to wait until the current state equals the "waitState".
      Parameters:
      waitState - State to wait until.
      Throws:
      InterruptedException
    • waitWhile

      public void waitWhile(State waitState) throws InterruptedException
      Causes the current Thread to wait while the current state equals the "waitState".
      Parameters:
      waitState - State to wait during.
      Throws:
      InterruptedException
    • toString

      public String toString()
      Returns the String representation of the current state.
      Overrides:
      toString in class Object