Record Class ChartPoint

java.lang.Object
java.lang.Record
com.arbergashi.charts.model.ChartPoint
All Implemented Interfaces:
Serializable, Comparable<ChartPoint>

public record ChartPoint(double x, double y, double weight, double min, double max, String label) extends Record implements Serializable, Comparable<ChartPoint>
Enterprise data point representation for the ArberGashi engine. Optimized for JDK 25+: value-object semantics and fluent API. Suitable for high-frequency trading, scientific data and IoT sensor streams.
Since:
2025-12-30
Version:
1.0.0
Author:
Arber Gashi
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChartPoint(double x, double y)
     
    ChartPoint(double x, double y, double weight, double min, double max, String label)
    Compact canonical constructor with validation for numerical stability.
    ChartPoint(double x, double y, String label)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    double
    Computes the span between max and min (e.g., volatility).
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Checks whether the point lies within its min/max range.
    Returns the value of the label record component.
    double
    max()
    Returns the value of the max record component.
    double
    min()
    Returns the value of the min record component.
    static ChartPoint
    of(double x, double y)
     
    static ChartPoint
    ofOHLC(double x, double open, double high, double low, double close)
    Specialized for candlestick semantics: y==close, weight==open.
    static ChartPoint
    ofRange(double x, double y, double min, double max)
    Specialized for error bars or box plots.
    final String
    Returns a string representation of this record class.
    double
    Returns the value of the weight record component.
    Returns a copy with a new label.
    withWeight(double weight)
    Returns a copy with the provided weight, original remains unchanged.
    double
    x()
    Returns the value of the x record component.
    double
    y()
    Returns the value of the y record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ChartPoint

      public ChartPoint(double x, double y, double weight, double min, double max, String label)
      Compact canonical constructor with validation for numerical stability.
    • ChartPoint

      public ChartPoint(double x, double y)
    • ChartPoint

      public ChartPoint(double x, double y, String label)
  • Method Details

    • of

      public static ChartPoint of(double x, double y)
    • ofOHLC

      public static ChartPoint ofOHLC(double x, double open, double high, double low, double close)
      Specialized for candlestick semantics: y==close, weight==open.
    • ofRange

      public static ChartPoint ofRange(double x, double y, double min, double max)
      Specialized for error bars or box plots.
    • withWeight

      public ChartPoint withWeight(double weight)
      Returns a copy with the provided weight, original remains unchanged.
    • withLabel

      public ChartPoint withLabel(String label)
      Returns a copy with a new label.
    • isWithinRange

      public boolean isWithinRange()
      Checks whether the point lies within its min/max range.
    • delta

      public double delta()
      Computes the span between max and min (e.g., volatility).
    • compareTo

      public int compareTo(ChartPoint other)
      Specified by:
      compareTo in interface Comparable<ChartPoint>
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • weight

      public double weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component
    • min

      public double min()
      Returns the value of the min record component.
      Returns:
      the value of the min record component
    • max

      public double max()
      Returns the value of the max record component.
      Returns:
      the value of the max record component
    • label

      public String label()
      Returns the value of the label record component.
      Returns:
      the value of the label record component