Class RealQuantityAdapter

java.lang.Object
org.episteme.core.measure.adapters.RealQuantityAdapter

public final class RealQuantityAdapter extends Object
Adapters between Episteme Real numbers and JSR-385 Quantities.

This class provides bidirectional conversion between Episteme's exact/approximate Real numbers and JSR-385 Quantity values.

* @author Silvere Martin-Michiellot
Since:
1.0
Author:
Gemini AI (Google DeepMind)
  • Method Details

    • toQuantity

      public static <Q extends Quantity<Q>> Quantity<Q> toQuantity(Real value, Unit<Q> unit)
      Converts a Episteme Real to a JSR-385 Quantity.
      Type Parameters:
      Q - the quantity type
      Parameters:
      value - the Real value
      unit - the target unit
      Returns:
      the equivalent Quantity
    • toReal

      public static Real toReal(Quantity<?> quantity)
      Converts a JSR-385 Quantity to a Episteme Real.
      Parameters:
      quantity - the quantity to convert
      Returns:
      the equivalent Real value
    • toExactReal

      public static Real toExactReal(Quantity<?> quantity)
      Converts a JSR-385 Quantity to a Episteme exact Real.
      Parameters:
      quantity - the quantity to convert
      Returns:
      the equivalent exact Real value
    • getValue

      public static <Q extends Quantity<Q>> Real getValue(Quantity<Q> quantity, Unit<Q> unit)
      Extracts the numeric value from a Quantity as a Real.
      Type Parameters:
      Q - the quantity type
      Parameters:
      quantity - the quantity
      unit - the unit to convert to
      Returns:
      the value in the specified unit as a Real