Class ResultDoubleValue

java.lang.Object
com.amalgamasimulation.studies.result.ResultElement
com.amalgamasimulation.studies.result.ResultDoubleValue
All Implemented Interfaces:
ResultValue
Direct Known Subclasses:
SummaryResultGroup

public class ResultDoubleValue extends ResultElement implements ResultValue
A result element representing a double precision floating-point value. Extends ResultElement and implements ResultValue to provide numeric value functionality within a hierarchical result structure.

This class provides methods to get and set the double value. It also provides formatting capabilities through the DoubleFormats enum.

  • Field Details

  • Constructor Details

    • ResultDoubleValue

      public ResultDoubleValue(double value)
      Constructs a new ResultDoubleValue with the specified value.
      Parameters:
      value - the double value to store
    • ResultDoubleValue

      public ResultDoubleValue(Supplier<Double> valueSupplier)
      Constructs a new ResultDoubleValue with a value supplier for lazy initialization. The supplier will be called exactly once when the value is first requested.
      Parameters:
      valueSupplier - the supplier providing the double value (cannot be null)
      Throws:
      NullPointerException - if the valueSupplier parameter is null
  • Method Details

    • value

      public Double value()
      Gets the double value of this element. If constructed with a supplier, this will trigger the first (and only) call to the supplier.
      Specified by:
      value in interface ResultValue
      Returns:
      the double value, which may be Double.NaN
    • format

      public Function<Double,String> format()
      Gets the current formatter function based on the configured format.
      Returns:
      a function that formats double values according to the current format
    • format

      public ResultDoubleValue format(DoubleFormats format)
      Sets the display format for this value.
      Parameters:
      format - the format to use (cannot be null)
      Returns:
      this element for method chaining
      Throws:
      NullPointerException - if the format parameter is null
    • getFormat

      public DoubleFormats getFormat()
      Gets the current display format for this value. Default format DoubleFormats.KMB.
      Returns:
      the current format setting
    • id

      public ResultDoubleValue id(String id)
      Description copied from class: ResultElement
      Sets the identifier for this element. The ID must be unique among siblings.
      Overrides:
      id in class ResultElement
      Parameters:
      id - the unique identifier for this element
      Returns:
      this element for method chaining