Q - The type of the quantity.public interface Quantity<Q extends Quantity<Q>>
Represents a quantitative property of a phenomenon, body, or substance, that can be quantified by measurement. Mass, time,
distance, heat, and angular separation are among the familiar examples of
quantitative properties.
Unit pound = ... Quantity size = ... Sensor
thermometer = ... Vector3D aircraftSpeed = ...
| Modifier and Type | Method and Description |
|---|---|
Quantity<Q> |
add(Quantity<Q> augend)
Returns the sum of this
Quantity with the one specified. |
<T extends Quantity<T>> |
asType(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(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. |
Number |
getValue()
Returns the value of this
Quantity. |
Quantity<?> |
inverse()
Returns a
Quantity whose unit is unit.inverse(). |
Quantity<Q> |
multiply(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. |
Quantity<Q> add(Quantity<Q> augend)
Quantity with the one specified.augend - the Quantity to be added.this + augend.Quantity<Q> subtract(Quantity<Q> subtrahend)
Quantity and the one
specified.subtrahend - the Quantity to be subtracted.this - that.Quantity<?> divide(Quantity<?> divisor)
Quantity divided by the Quantity
specified.divisor - the Quantity divisor.this / that.ClassCastException - if the type of an element
in the specified operation is incompatible with this
quantity
(optional)Quantity<Q> divide(Number divisor)
Quantity divided by the Number
specified.divisor - the Number divisor.this / that.Quantity<?> multiply(Quantity<?> multiplier)
Quantity with the one specified.that - the Quantity multiplier.this * multiplier.ClassCastException - if the type of an element
in the specified operation is incompatible with this
quantity
(optional)Quantity<Q> multiply(Number multiplier)
Quantity with the Number value
specified.that - the Number multiplier.this * multiplier.Quantity<?> inverse()
Quantity whose unit is unit.inverse().Quantity with this.getUnit().inverse().Quantity<Q> to(Unit<Q> unit)
Quantity converted into another (compatible) Unit.unit - the Unit to convert to.<T extends Quantity<T>> Quantity<T> asType(Class<T> type) throws ClassCastException
ClassCastException if the dimension of the specified
quantity and this measure unit's dimension do not match. For example:
Quantity length = BaseQuantity.of("2 km").asType(Length.class);
or
Quantity C = length.multiply(299792458).divide(second).asType(Speed.class);
T - The type of the quantity.type - the quantity class identifying the nature of the quantity.ClassCastException - if the dimension of this unit is different from the specified
quantity dimension.UnsupportedOperationException - if the specified quantity class does not have a public static
field named "UNIT" holding the SI unit for the quantity.Unit.asType(Class)Copyright © 2014 Jean-Marie Dautelle, Werner Keil, V2COM. All Rights Reserved.