Module jtrim.query

Class OrderedData<DataType>

java.lang.Object
org.jtrim2.concurrent.query.OrderedData<DataType>
Type Parameters:
DataType - the type of the actual data

public final class OrderedData<DataType> extends Object
Defines a data with an index which indicates how accurate the data is. The higher the value of the index, the more accurate the data is.

This class is intended to be used with AsyncDataLink instances when it is hard forward data in the order of their accuracy but the accuracy can be quantified with an index. This way wrapping listeners using the AsyncHelper.makeSafeOrderedListener(AsyncDataListener) method can guarantee that a less accurate data will not be forwarded to the actual, generic listener after a more accurate data.

Thread safety

The methods of this class are safe to be accessed by multiple threads concurrently. Instances of this class cannot be directly modified, only its data if it is mutable. In case this data object is immutable (and it is recommended to be so), then the OrderedData instance is completely immutable.

Synchronization transparency

The methods of this class are synchronization transparent.
See Also:
  • Constructor Details

    • OrderedData

      public OrderedData(long index, DataType rawData)
      Initializes this OrderedData with the given index and data.
      Parameters:
      index - the index determining how accurate the data is. This argument can be any possible long value.
      rawData - the actual data whose accuracy is described by the specified index. This argument is allowed to be null.
  • Method Details

    • getIndex

      public long getIndex()
      Returns the index defining how accurate the associated data is. Higher index means more accurate data.
      Returns:
      the index defining how accurate the associated data is. This method returns the value specified at construction time and can be any possible long value.
    • getRawData

      public DataType getRawData()
      Returns the actual data whose accuracy is described by the index. Higher index means more accurate data.
      Returns:
      the actual data whose accuracy is described by the index. This method returns the value specified at construction time and may return null.
    • toString

      public String toString()
      Returns the string representation of this OrderedData in no particular format. The string representation contains both the index and the data.

      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.