Class SimpleDataState

java.lang.Object
org.jtrim2.concurrent.query.SimpleDataState
All Implemented Interfaces:
AsyncDataState

public final class SimpleDataState extends Object implements AsyncDataState
Defines an AsyncDataState with a specific double value as the state of progress and a string describing the current state.

Thread safety

Instances of this class are completely immutable and as such, safe to be accessed by multiple threads concurrently.

Synchronization transparency

The methods of this class are synchronization transparent.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleDataState(String state, double progress)
    Initializes the SimpleDataState with the specified string describing the current state of progress and a double value within the range [0.0, 1.0] describing the estimated numerical state of progress.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the estimated state of progress within the range [0.0, 1.0].
    Returns the string describing the current state of progress.
    Returns the string representation of this SimpleDataState in no particular format.

    Methods inherited from class java.lang.Object

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

    • SimpleDataState

      public SimpleDataState(String state, double progress)
      Initializes the SimpleDataState with the specified string describing the current state of progress and a double value within the range [0.0, 1.0] describing the estimated numerical state of progress.
      Parameters:
      state - the string describing the current state of progress. This argument cannot be null.
      progress - the estimated numerical state of progress within the range [0.0, 1.0]. The value of this argument is not verified by this constructor.
      Throws:
      NullPointerException - thrown if the specified string state is null
  • Method Details

    • getState

      public String getState()
      Returns the string describing the current state of progress. This method returns the value specified at construction time.
      Returns:
      the string describing the current state of progress. This method never returns null.
    • getProgress

      public double getProgress()
      Returns the estimated state of progress within the range [0.0, 1.0].

      The progress value 0.0 means that the process just started and 1.0 means that it has been completed or very close to being completed.

      Note that although this method should return a value within the range [0.0, 1.0], callers should expect any other possible double values (including NaNs) because it is easy to make rounding errors with floating point arithmetic. For values lower than 0.0, callers should assume 0.0 and for values greater than 1.0, they should assume 1.0.

      This implementation simply returns the value specified at construction time.

      Specified by:
      getProgress in interface AsyncDataState
      Returns:
      the estimated state of progress within the range [0.0, 1.0]. Note that callers should expect that this method may return values out of the designed range.
    • toString

      public String toString()
      Returns the string representation of this SimpleDataState in no particular format. The string representation contains both estimated numerical state of progress and the string describing the state of progress.

      This method is intended to be used for debugging only.

      Overrides:
      toString in class Object
      Returns:
      the string representation of this object in no particular format. This method never returns null.