public interface ITypedQuantity<U extends TypedUnit<U>> extends IQuantity
IQuantity
. This construction exists to reduce clutter for
casual users of IQuantity, while still providing type safety for internal implementations.
(Proposed "self-variance" extensions to Java, in JDK 9 or beyond, may directly support this with
a single interface.)AUTO, EXACT, VERBOSE
Modifier and Type | Method and Description |
---|---|
ITypedQuantity<U> |
add(ITypedQuantity<LinearUnit> addend) |
ITypedQuantity<U> |
floorQuantize(ITypedQuantity<LinearUnit> quanta) |
KindOfQuantity<U> |
getType()
Get the kind of this quantity.
|
U |
getUnit() |
ITypedQuantity<U> |
in(U targetUnit)
Get this quantity expressed in the unit
targetUnit . |
String |
interactiveFormat(boolean allowCustomUnit) |
String |
localizedFormat(boolean useBreakingSpace,
boolean allowCustomUnit) |
ITypedQuantity<U> |
multiply(double factor)
Returns a new quantity that is this quantity multiplied with
factor , if this is a
linear quantity. |
ITypedQuantity<U> |
multiply(long factor)
Returns a new quantity that is this quantity multiplied with
factor , if this is a
linear quantity. |
ITypedQuantity<LinearUnit> |
subtract(ITypedQuantity<U> subtrahend) |
add, clampedFloorIn, clampedIntFloorIn, clampedLongValueIn, doubleValue, doubleValueIn, in, interactiveFormat, isLinear, longValue, longValueIn, longValueIn, numberValue, numberValueIn, persistableString, ratioTo, subtract
displayUsing
compareTo
KindOfQuantity<U> getType()
IQuantity
U getUnit()
ITypedQuantity<U> in(U targetUnit)
targetUnit
. Note that as a result of this
conversion, precision may be lost. Note that this method differs from IQuantity.in(IUnit)
only
by stricter typing.targetUnit
IllegalArgumentException
- if targetUnit
is not of the same kind of quantityITypedQuantity<U> add(ITypedQuantity<LinearUnit> addend) throws IllegalArgumentException
IllegalArgumentException
ITypedQuantity<LinearUnit> subtract(ITypedQuantity<U> subtrahend) throws IllegalArgumentException
IllegalArgumentException
ITypedQuantity<U> multiply(long factor) throws UnsupportedOperationException
IQuantity
factor
, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException
will be thrown.multiply
in interface IQuantity
factor
UnsupportedOperationException
- if this quantity is not linearITypedQuantity<U> multiply(double factor) throws UnsupportedOperationException
IQuantity
factor
, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException
will be thrown.multiply
in interface IQuantity
factor
UnsupportedOperationException
- if this quantity is not linearITypedQuantity<U> floorQuantize(ITypedQuantity<LinearUnit> quanta)
String interactiveFormat(boolean allowCustomUnit)
String localizedFormat(boolean useBreakingSpace, boolean allowCustomUnit)
Copyright © 2020. All rights reserved.