Package javax.measure

Interface Quantity<Q extends Quantity<Q>>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Quantity<Q> add​(Quantity<Q> augend)
      Returns the sum of this Quantity with the one specified.
      <T extends Quantity<T>>
      Quantity<T>
      asType​(java.lang.Class<T> type)
      Casts this quantity to a parameterized unit of specified nature or throw a ClassCastException if the dimension of the specified quantity and this measure unit's dimension do not match.
      Quantity<Q> divide​(java.lang.Number divisor)
      Returns the product of this Quantity divided by the Number specified.
      Quantity<?> divide​(Quantity<?> divisor)
      Returns the product of this Quantity divided by the Quantity specified.
      Unit<Q> getUnit()
      Returns the unit of this Quantity.
      java.lang.Number getValue()
      Returns the value of this Quantity.
      Quantity<?> inverse()
      Returns a Quantity whose unit is unit.inverse().
      Quantity<Q> multiply​(java.lang.Number multiplier)
      Returns the product of this Quantity with the Number value specified.
      Quantity<?> multiply​(Quantity<?> multiplier)
      Returns the product of this Quantity with the one specified.
      Quantity<Q> subtract​(Quantity<Q> subtrahend)
      Returns the difference between this Quantity and the one specified.
      Quantity<Q> to​(Unit<Q> unit)
      Returns this Quantity converted into another (compatible) Unit.
    • Method Detail

      • add

        Quantity<Q> add​(Quantity<Q> augend)
        Returns the sum of this Quantity with the one specified.
        Parameters:
        augend - the Quantity to be added.
        Returns:
        this + augend.
      • subtract

        Quantity<Q> subtract​(Quantity<Q> subtrahend)
        Returns the difference between this Quantity and the one specified.
        Parameters:
        subtrahend - the Quantity to be subtracted.
        Returns:
        this - that.
      • divide

        Quantity<?> divide​(Quantity<?> divisor)
        Returns the product of this Quantity divided by the Quantity specified.
        Parameters:
        divisor - the Quantity divisor.
        Returns:
        this / that.
        Throws:
        java.lang.ClassCastException - if the type of an element in the specified operation is incompatible with this quantity (optional)
      • divide

        Quantity<Q> divide​(java.lang.Number divisor)
        Returns the product of this Quantity divided by the Number specified.
        Parameters:
        divisor - the Number divisor.
        Returns:
        this / that.
      • multiply

        Quantity<?> multiply​(Quantity<?> multiplier)
        Returns the product of this Quantity with the one specified.
        Parameters:
        multiplier - the Quantity multiplier.
        Returns:
        this * multiplier.
        Throws:
        java.lang.ClassCastException - if the type of an element in the specified operation is incompatible with this quantity (optional)
      • multiply

        Quantity<Q> multiply​(java.lang.Number multiplier)
        Returns the product of this Quantity with the Number value specified.
        Parameters:
        multiplier - the Number multiplier.
        Returns:
        this * multiplier.
      • inverse

        Quantity<?> inverse()
        Returns a Quantity whose unit is unit.inverse().
        Returns:
        Quantity with this.getUnit().inverse().
      • to

        Quantity<Q> to​(Unit<Q> unit)
        Returns this Quantity converted into another (compatible) Unit.
        Parameters:
        unit - the Unit to convert to.
        Returns:
        the converted result.
      • asType

        <T extends Quantity<T>> Quantity<T> asType​(java.lang.Class<T> type)
                                            throws java.lang.ClassCastException
        Casts this quantity to a parameterized unit of specified nature or throw a ClassCastException if the dimension of the specified quantity and this measure unit's dimension do not match. For example:

        Quantity<Length> length = Quantities.getQuantity("2 km").asType(Length.class); or Quantity<Speed> C = length.multiply(299792458).divide(second).asType(Speed.class);

        Type Parameters:
        T - The type of the quantity.
        Parameters:
        type - the quantity class identifying the nature of the quantity.
        Returns:
        this quantity parameterized with the specified type.
        Throws:
        java.lang.ClassCastException - if the dimension of this unit is different from the specified quantity dimension.
        java.lang.UnsupportedOperationException - if the specified quantity class does not have a SI unit for the quantity.
        See Also:
        Unit.asType(Class)
      • getValue

        java.lang.Number getValue()
        Returns the value of this Quantity.
        Returns:
        a value.
      • getUnit

        Unit<Q> getUnit()
        Returns the unit of this Quantity.
        Returns:
        the unit (shall not be null).