Record Class SourceChangePoint

java.lang.Object
java.lang.Record
com.inductiveautomation.historian.common.model.data.SourceChangePoint
All Implemented Interfaces:
ChangePoint<SourceChangePoint.SourceMapKey>, TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>, Comparable<TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>>

public record SourceChangePoint(SourceChangePoint.SourceMapKey value, Instant timestamp) extends Record implements ChangePoint<SourceChangePoint.SourceMapKey>
Represents a change point for source changes.

This record encapsulates the details of a source change, including the value of the change and the timestamp when the change occurred. It implements the ChangePoint interface with SourceChangePoint.SourceMapKey as the type parameter.

  • Constructor Details

    • SourceChangePoint

      public SourceChangePoint(SourceChangePoint.SourceMapKey value, Instant timestamp)
      Constructs a SourceChangePoint with null checks and a default timestamp.

      Ensures that the value is not null and assigns the current time as the default timestamp if none is provided.

      Parameters:
      value - The source change value, must not be null.
      timestamp - The timestamp of the change, defaults to the current time if null.
  • Method Details

    • source

      public QualifiedPath source()
      Retrieves the old source path of the change.
      Specified by:
      source in interface TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>
      Returns:
      The old source path.
    • type

      public StandardChangePointType type()
      Retrieves the type of the change point.
      Specified by:
      type in interface ChangePoint<SourceChangePoint.SourceMapKey>
      Specified by:
      type in interface TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>
      Returns:
      The type of the change point, which is StandardChangePointType.SOURCE_CHANGE.
    • oldSource

      public QualifiedPath oldSource()
      Retrieves the old source path of the change.
      Returns:
      The old source path.
    • newSource

      public QualifiedPath newSource()
      Retrieves the new source path of the change.
      Returns:
      The new source path, or null if this is a retirement.
    • isRetirement

      public boolean isRetirement()
      Checks if this change represents a retirement.
      Returns:
      True if the new source is null, indicating a retirement.
    • isDeletion

      public boolean isDeletion()
      Checks if this change represents a deletion.
      Specified by:
      isDeletion in interface ChangePoint<SourceChangePoint.SourceMapKey>
      Returns:
      True if this change represents a retirement (new source is null).
    • retirement

      public static SourceChangePoint retirement(QualifiedPath oldSource)
      Creates a retirement change point with the current timestamp.
      Parameters:
      oldSource - The source being retired, must not be null.
      Returns:
      A new SourceChangePoint representing the retirement.
    • retirement

      public static SourceChangePoint retirement(QualifiedPath oldSource, Instant timestamp)
      Creates a retirement change point with a specified timestamp.
      Parameters:
      oldSource - The source being retired, must not be null.
      timestamp - The timestamp of the retirement, must not be null.
      Returns:
      A new SourceChangePoint representing the retirement.
    • update

      public static SourceChangePoint update(QualifiedPath oldSource, QualifiedPath newSource)
      Creates an update change point with the current timestamp.
      Parameters:
      oldSource - The old source path, must not be null.
      newSource - The new source path, must not be null.
      Returns:
      A new SourceChangePoint representing the update.
    • update

      public static SourceChangePoint update(QualifiedPath oldSource, QualifiedPath newSource, Instant timestamp)
      Creates an update change point with a specified timestamp.
      Parameters:
      oldSource - The old source path, must not be null.
      newSource - The new source path, must not be null.
      timestamp - The timestamp of the update, must not be null.
      Returns:
      A new SourceChangePoint representing the update.
    • merge

      public static SourceChangePoint merge(@Nullable SourceChangePoint earlier, SourceChangePoint later)
      Returns a SourceChangePoint representing the net effect of earlier followed by later, collapsing a chained rename so that, e.g., A->B then B->C produces A->C. The result inherits later's timestamp.

      If earlier is null, later is returned unchanged.

      Precondition: the two changes must form a chain — earlier.newSource() must equal later.oldSource(). Callers are responsible for upholding this; merging unrelated changes will silently drop later.oldSource() and produce a misleading result.

      If later is a retirement, the merged point is also a retirement of earlier.oldSource().

      Parameters:
      earlier - the prior change in the chain, or null.
      later - the next change in the chain, must not be null.
      Returns:
      a single change point describing the net move from earlier.oldSource() to later.newSource() (or a retirement of earlier.oldSource()).
    • 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

      Returns the value of the value record component.
      Specified by:
      value in interface ChangePoint<SourceChangePoint.SourceMapKey>
      Specified by:
      value in interface TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>
      Returns:
      the value of the value record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface TemporalPoint<SourceChangePoint.SourceMapKey,ChangePointType>
      Returns:
      the value of the timestamp record component