Top Description Fields Constructors Methods
tech.units.indriya.quantity

public final Class NumberQuantity<Q extends Quantity<Q>>

extends AbstractQuantity<Q extends Quantity<Q>>
Class Inheritance
Annotations
@API
status:MAINTAINED
Type Parameters
<Q>
The type of the quantity.
Static Imports
javax.measure.Quantity.Scale.ABSOLUTE, org.apiguardian.api.API.Status.MAINTAINED

Implementation of ComparableQuantity that holds a Java Number, which represented this quantity's amount.

This object is immutable.

Authors
Andi Huber, Werner Keil
Since
1.0
Version
2.3, May 14, 2021
See Also
AbstractQuantity, Quantity, ComparableQuantity

Field Summary

Modifier and TypeField and Description
private static final long
private final Number
Inherited from tech.units.indriya.AbstractQuantity:
NONEONE

Constructor Summary

AccessConstructor and Description
protected
NumberQuantity(Number number, Unit<Q> unit, Quantity.Scale sc)

protected
NumberQuantity(Number number, Unit<Q> unit)

Method Summary

Modifier and TypeMethod and Description
public ComparableQuantity<Q>
add(Quantity<Q>
the Quantity to be added.
that
)

Implements tech.units.indriya.ComparableQuantity.add.

Returns the sum of this Quantity with the one specified.

public ComparableQuantity<?>
divide(Quantity<?>
the Quantity divisor.
that
)

Implements tech.units.indriya.ComparableQuantity.divide.

Returns the quotient of this Quantity divided by the Quantity specified.

public ComparableQuantity<Q>
divide(Number
the Number divisor.
divisor
)

Implements tech.units.indriya.ComparableQuantity.divide.

Returns the quotient of this Quantity divided by the Number specified.

public Number
public ComparableQuantity<?>
inverse()

Implements tech.units.indriya.ComparableQuantity.inverse.

Returns a Quantity that is the multiplicative inverse of this Quantity, having reciprocal value and reciprocal unit as given by this.getUnit().inverse().

public ComparableQuantity<?>
multiply(Quantity<?>
the Quantity multiplicand.
that
)

Implements tech.units.indriya.ComparableQuantity.multiply.

Returns the product of this Quantity with the one specified.

public ComparableQuantity<Q>
multiply(Number
the Number multiplicand.
factor
)

Implements tech.units.indriya.ComparableQuantity.multiply.

Returns the product of this Quantity with the Number value specified.

public Quantity<Q>
negate()

Implements javax.measure.Quantity.negate.

Returns a Quantity whose value is (-this.getValue()).

public ComparableQuantity<Q>
subtract(Quantity<Q>
the Quantity to be subtracted.
that
)

Implements tech.units.indriya.ComparableQuantity.subtract.

Returns the difference between this Quantity and the one specified.

Inherited from tech.units.indriya.AbstractQuantity:
asTypecompareTodivideequalsgetScalegetUnithasFractionhasFractionhashCodeinverseisEquivalentToisGreaterThanisGreaterThanOrEqualToisLessThanisLessThanOrEqualTomultiplyparsetotoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides tech.units.indriya.AbstractQuantity.serialVersionUID.

valueback to summary
private final Number value

Constructor Detail

NumberQuantityback to summary
protected NumberQuantity(Number number, Unit<Q> unit, Quantity.Scale sc)
Since
2.0
NumberQuantityback to summary
protected NumberQuantity(Number number, Unit<Q> unit)

Method Detail

addback to summary
public ComparableQuantity<Q> add(Quantity<Q> that)

Implements tech.units.indriya.ComparableQuantity.add.

Doc from javax.measure.Quantity.add.

Returns the sum of this Quantity with the one specified. The result shall be as if this quantity and the given addend were converted to system unit before to be added, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<Q>

the Quantity to be added.

Returns:ComparableQuantity<Q>

this + addend.

Annotations
@Override
divideback to summary
public ComparableQuantity<?> divide(Quantity<?> that)

Implements tech.units.indriya.ComparableQuantity.divide.

Doc from javax.measure.Quantity.divide.

Returns the quotient of this Quantity divided by the Quantity specified. The result shall be as if this quantity and the given divisor were converted to system unit before to be divided, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<?>

the Quantity divisor.

Returns:ComparableQuantity<?>

this / divisor.

Annotations
@Override
divideback to summary
public ComparableQuantity<Q> divide(Number divisor)

Implements tech.units.indriya.ComparableQuantity.divide.

Doc from javax.measure.Quantity.divide.

Returns the quotient of this Quantity divided by the Number specified. The result shall be as if this quantity was converted to system unit before to be divided, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
divisor:Number

the Number divisor.

Returns:ComparableQuantity<Q>

this / divisor.

Annotations
@Override
getValueback to summary
public Number getValue()

Implements abstract tech.units.indriya.AbstractQuantity.getValue.

Implements javax.measure.Quantity.getValue, tech.uom.lib.common.function.ValueSupplier.getValue.

Doc from tech.units.indriya.AbstractQuantity.getValue.

Returns the numeric value of the quantity.

Returns:Number

the quantity value.

Annotations
@Override
inverseback to summary
public ComparableQuantity<?> inverse()

Implements tech.units.indriya.ComparableQuantity.inverse.

Doc from javax.measure.Quantity.inverse.

Returns a Quantity that is the multiplicative inverse of this Quantity, having reciprocal value and reciprocal unit as given by this.getUnit().inverse().

Returns:ComparableQuantity<?>

reciprocal Quantity

Annotations
@Override
multiplyback to summary
public ComparableQuantity<?> multiply(Quantity<?> that)

Implements tech.units.indriya.ComparableQuantity.multiply.

Doc from javax.measure.Quantity.multiply.

Returns the product of this Quantity with the one specified. The result shall be as if this quantity and the given multiplicand were converted to system unit before to be multiplied, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<?>

the Quantity multiplicand.

Returns:ComparableQuantity<?>

this * multiplicand.

Annotations
@Override
multiplyback to summary
public ComparableQuantity<Q> multiply(Number factor)

Implements tech.units.indriya.ComparableQuantity.multiply.

Doc from javax.measure.Quantity.multiply.

Returns the product of this Quantity with the Number value specified. The result shall be as if this quantity was converted to system unit before to be multiplied, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
factor:Number

the Number multiplicand.

Returns:ComparableQuantity<Q>

this * multiplicand.

Annotations
@Override
negateback to summary
public Quantity<Q> negate()

Implements javax.measure.Quantity.negate.

Doc from javax.measure.Quantity.negate.

Returns a Quantity whose value is (-this.getValue()).

Returns:Quantity<Q>

-this.

Annotations
@Override
subtractback to summary
public ComparableQuantity<Q> subtract(Quantity<Q> that)

Implements tech.units.indriya.ComparableQuantity.subtract.

Doc from javax.measure.Quantity.subtract.

Returns the difference between this Quantity and the one specified. The result shall be as if this quantity and the given subtrahend were converted to system unit before to be subtracted, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<Q>

the Quantity to be subtracted.

Returns:ComparableQuantity<Q>

this - subtrahend.

Annotations
@Override