Record Class HierarchicalDataPoint

java.lang.Object
java.lang.Record
com.arbergashi.charts.model.HierarchicalDataPoint
Record Components:
name - The name of the data point (e.g., "Users", "System").
value - The quantitative value of this node. For parent nodes, this is often the sum of its children.
children - A list of child nodes.

public record HierarchicalDataPoint(String name, double value, List<HierarchicalDataPoint> children) extends Record
Represents a node in a hierarchical data structure, used for charts like Sunburst or Treemaps.
Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Constructor Details

    • HierarchicalDataPoint

      public HierarchicalDataPoint(String name, double value, List<HierarchicalDataPoint> children)
      Creates a hierarchical data point, ensuring the children list is never null.
    • HierarchicalDataPoint

      public HierarchicalDataPoint(String name, double value)
      Convenience constructor for a leaf node (a node with no children).
      Parameters:
      name - The name of the leaf node.
      value - The value of the leaf node.
  • Method Details

    • isLeaf

      public boolean isLeaf()
      Checks if this node is a leaf (has no children).
      Returns:
      true if this node has no children, false otherwise.
    • 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.
    • name

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

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

      public List<HierarchicalDataPoint> children()
      Returns the value of the children record component.
      Returns:
      the value of the children record component