Package org.jtrim2.concurrent.query
Class SimpleDataState
java.lang.Object
org.jtrim2.concurrent.query.SimpleDataState
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionSimpleDataState(String state, double progress) Initializes theSimpleDataStatewith 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
-
Constructor Details
-
SimpleDataState
Initializes theSimpleDataStatewith 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 benull.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 isnull
-
-
Method Details
-
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:
getProgressin interfaceAsyncDataState- 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
Returns the string representation of thisSimpleDataStatein no particular format. The string representation contains both estimatednumerical state of progressand thestringdescribing the state of progress.This method is intended to be used for debugging only.
-