Q - The type of the quantity.public interface Quantity<Q extends Quantity<Q>>
Mass, time, distance, heat, and angular separation are among the familiar examples of quantitative properties.
Unit<Mass> pound = ... Quantity<Length> size = ... Sensor<Temperature>
thermometer = ... Vector3D<Speed> aircraftSpeed = ...
Unit,
Wikipedia: Quantity,
Martin Fowler - Quantity| 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.multiplier - 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.multiplier - 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> length = Quantities.getQuantity("2 km").asType(Length.class);
or
Quantity<Speed> 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 SI unit for the quantity.Unit.asType(Class)Copyright © 2014–2016 Jean-Marie Dautelle, Werner Keil, V2COM. All rights reserved.