Record Class AggregatedDataPoint<V,A extends AggregationType>

java.lang.Object
java.lang.Record
com.inductiveautomation.historian.common.model.data.AggregatedDataPoint<V,A>
Type Parameters:
V - The type of the value contained in the aggregated data point.
A - The type of the aggregation, extending AggregationType.
All Implemented Interfaces:
AggregatedPoint<V,A>, DataPoint<V>, SnapshotCapable, TemporalPoint<V,DataPointType>, Comparable<TemporalPoint<V,DataPointType>>

public record AggregatedDataPoint<V,A extends AggregationType>(V value, QualityCode quality, Instant timestamp, QualifiedPath source, A extends AggregationType aggregationType, Optional<Instant> snapshotTimestamp) extends Record implements AggregatedPoint<V,A>
Represents an aggregated data point with its value, quality, and aggregation information.

This record encapsulates the value, quality, timestamp, source, aggregation type, and an optional snapshot timestamp of an aggregated data point. It ensures that the source and aggregation type are not null, assigns a default quality of QualityCode.Good if null, and sets the current timestamp if none is provided.

  • Constructor Details

    • AggregatedDataPoint

      public AggregatedDataPoint(V value, QualityCode quality, Instant timestamp, QualifiedPath source, A aggregationType, Optional<Instant> snapshotTimestamp)
      Constructs an AggregatedDataPoint instance.

      Validates that the source and aggregation type are not null. If the quality is null, it defaults to QualityCode.Good. If the timestamp is null, it defaults to the current time.

      Throws:
      NullPointerException - If the source or aggregation type is null.
  • Method Details

    • builder

      public static <V, A extends AggregationType> AggregatedDataPoint.Builder<V,A> builder(QualifiedPath source, A aggregationType)
      Creates a new builder for AggregatedDataPoint.
      Type Parameters:
      V - The type of the value.
      A - The type of the aggregation, extending AggregationType.
      Parameters:
      source - The source of the data point. Must not be null.
      aggregationType - The type of aggregation. Must not be null.
      Returns:
      A new AggregatedDataPoint.Builder instance for constructing AggregatedDataPoint objects.
    • from

      public static <V, A extends AggregationType> AggregatedDataPoint<V,A> from(DataPoint<V> point, A aggregationType)
      Creates an aggregated data point from an existing data point.
      Type Parameters:
      V - The type of the value.
      A - The type of the aggregation, extending AggregationType.
      Parameters:
      point - The source data point. Must not be null.
      aggregationType - The type of aggregation. Must not be null.
      Returns:
      A new AggregatedDataPoint instance based on the provided data point and aggregation type.
    • withSnapshot

      public AggregatedDataPoint<V,A> withSnapshot(Instant snapshotTime)
      Creates a new aggregated data point with an updated snapshot timestamp.
      Specified by:
      withSnapshot in interface SnapshotCapable
      Parameters:
      snapshotTime - The new snapshot timestamp. Must not be null.
      Returns:
      A new AggregatedDataPoint instance with the updated snapshot timestamp.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public V value()
      Returns the value of the value record component.
      Specified by:
      value in interface DataPoint<V>
      Specified by:
      value in interface TemporalPoint<V,A extends AggregationType>
      Returns:
      the value of the value record component
    • quality

      public QualityCode quality()
      Returns the value of the quality record component.
      Specified by:
      quality in interface DataPoint<V>
      Returns:
      the value of the quality record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface TemporalPoint<V,A extends AggregationType>
      Returns:
      the value of the timestamp record component
    • source

      public QualifiedPath source()
      Returns the value of the source record component.
      Specified by:
      source in interface TemporalPoint<V,A extends AggregationType>
      Returns:
      the value of the source record component
    • aggregationType

      public A aggregationType()
      Returns the value of the aggregationType record component.
      Specified by:
      aggregationType in interface AggregatedPoint<V,A extends AggregationType>
      Returns:
      the value of the aggregationType record component
    • snapshotTimestamp

      public Optional<Instant> snapshotTimestamp()
      Returns the value of the snapshotTimestamp record component.
      Specified by:
      snapshotTimestamp in interface SnapshotCapable
      Returns:
      the value of the snapshotTimestamp record component