Record Class AggregateSpec

java.lang.Object
java.lang.Record
com.inductiveautomation.historian.common.model.options.AggregateSpec

public record AggregateSpec(AggregationType type, AggregateParams parameters) extends Record
An aggregate's type and typed parameters. The runtime class of parameters must match type.parameterSchema().recordType(); construction fails otherwise.

Use of(AggregationType) for an unparameterized aggregate (parameters are NoParams.INSTANCE) and the canonical constructor with a typed record for a parameterized one.

  • Constructor Details

    • AggregateSpec

      public AggregateSpec(AggregationType type, AggregateParams parameters)
      Creates an instance of a AggregateSpec record class.
      Parameters:
      type - the value for the type record component
      parameters - the value for the parameters record component
  • Method Details

    • of

      public static AggregateSpec of(AggregationType type)
      Creates the spec of an unparameterized aggregate.
      Parameters:
      type - the aggregate; its schema must be ParameterSchema.EMPTY.
      Returns:
      the spec, carrying NoParams.INSTANCE.
    • from

      public static AggregateSpec from(AggregationType type, Map<String,Object> values)
      Creates a spec from a flat parameters map, such as an AggregatedEntry.parameters() payload. Keys the map lacks take each field's declared default; an aggregate with an empty schema yields NoParams.INSTANCE whatever the map holds.
      Parameters:
      type - the aggregate.
      values - the parameter values by field name.
      Returns:
      the spec.
    • id

      public AggregateId id()
      Returns type().id().
      Returns:
      the aggregate id.
    • 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.
    • type

      public AggregationType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • parameters

      public AggregateParams parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component