Class FloatQuantity<Q extends javax.measure.Quantity<Q>>

java.lang.Object
tech.units.indriya.AbstractQuantity<Q>
tech.units.indriya.quantity.FloatQuantity<Q>
Type Parameters:
Q - The type of the quantity.
All Implemented Interfaces:
Serializable, Comparable<javax.measure.Quantity<Q>>, javax.measure.Quantity<Q>, ComparableQuantity<Q>, tech.uom.lib.common.function.QuantityConverter<Q>, tech.uom.lib.common.function.UnitSupplier<Q>, tech.uom.lib.common.function.ValueSupplier<Number>

final class FloatQuantity<Q extends javax.measure.Quantity<Q>> extends AbstractQuantity<Q>
An amount of quantity, consisting of a float and a Unit. FloatQuantity objects are immutable.
Since:
1.0.7
Version:
0.4, $Date: 2017-05-28 $
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • value

      final float value
  • Constructor Details

    • FloatQuantity

      public FloatQuantity(float value, javax.measure.Unit<Q> unit)
  • Method Details

    • getValue

      public Float getValue()
      Description copied from class: AbstractQuantity
      Returns the numeric value of the quantity.
      Specified by:
      getValue in interface javax.measure.Quantity<Q extends javax.measure.Quantity<Q>>
      Specified by:
      getValue in interface tech.uom.lib.common.function.ValueSupplier<Q extends javax.measure.Quantity<Q>>
      Specified by:
      getValue in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
      Returns:
      the quantity value.
    • doubleValue

      public double doubleValue(javax.measure.Unit<Q> unit)
      Specified by:
      doubleValue in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
    • longValue

      public long longValue(javax.measure.Unit<Q> unit)
      Overrides:
      longValue in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
    • addRaw

      private ComparableQuantity<Q> addRaw(Number a, Number b, javax.measure.Unit<Q> unit)
    • add

      public ComparableQuantity<Q> add(javax.measure.Quantity<Q> that)
      See Also:
      • Quantity.add(Quantity)
    • subtract

      public ComparableQuantity<Q> subtract(javax.measure.Quantity<Q> that)
      See Also:
      • Quantity.subtract(Quantity)
    • multiply

      public ComparableQuantity<?> multiply(javax.measure.Quantity<?> that)
      See Also:
      • Quantity.multiply(Quantity)
    • multiply

      public ComparableQuantity<Q> multiply(Number that)
      See Also:
      • Quantity.multiply(Number)
    • divide

      public ComparableQuantity<?> divide(javax.measure.Quantity<?> that)
      See Also:
      • Quantity.divide(Quantity)
    • inverse

      public ComparableQuantity<Q> inverse()
      See Also:
      • Quantity.inverse()
    • divide

      public ComparableQuantity<Q> divide(Number that)
      See Also:
      • Quantity.divide(Number)
    • equals

      public boolean equals(Object obj)
      Description copied from class: AbstractQuantity
      Compares this quantity against the specified object for strict equality (same unit and same amount).

      Similarly to the BigDecimal.equals(java.lang.Object) method which consider 2.0 and 2.00 as different objects because of different internal scales, quantities such as Quantities.getQuantity(3.0, KILOGRAM) Quantities.getQuantity(3, KILOGRAM) and Quantities.getQuantity("3 kg") might not be considered equals because of possible differences in their implementations.

      To compare quantities stated using different units or using different amount implementations the compareTo or equals(Quantity, epsilon, epsilonUnit) methods should be used.

      Overrides:
      equals in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
      Parameters:
      obj - the object to compare with.
      Returns:
      this.getUnit.equals(obj.getUnit()) && this.getValue().equals(obj.getValue())
    • isBig

      public boolean isBig()
      Specified by:
      isBig in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
    • decimalValue

      public BigDecimal decimalValue(javax.measure.Unit<Q> unit) throws ArithmeticException
      Specified by:
      decimalValue in class AbstractQuantity<Q extends javax.measure.Quantity<Q>>
      Throws:
      ArithmeticException