public static class ScalarQuantity.DoubleStored<U extends TypedUnit<U>> extends ScalarQuantity<U>
ScalarQuantity.DoubleStored<U extends TypedUnit<U>>, ScalarQuantity.LongStored<U extends TypedUnit<U>>
Modifier and Type | Field and Description |
---|---|
private double |
numericalValue |
private static long |
serialVersionUID |
unit
AUTO, EXACT, VERBOSE
Modifier | Constructor and Description |
---|---|
protected |
DoubleStored(double numericalValue,
U unit) |
Modifier and Type | Method and Description |
---|---|
ITypedQuantity<U> |
add(ITypedQuantity<LinearUnit> addend) |
long |
clampedFloorIn(IUnit targetUnit)
Get the
long value closest to the floor of the numerical quantity value that this
quantity would have if expressed in the unit targetUnit . |
int |
clampedIntFloorIn(IUnit targetUnit)
Get the
int value closest to the floor of the numerical quantity value that this
quantity would have if expressed in the unit targetUnit . |
long |
clampedLongValueIn(IUnit targetUnit)
Get the
long value closest to the numerical quantity value that this quantity would
have if expressed in the unit targetUnit . |
double |
doubleValue()
Get the numerical quantity value of this quantity as a
double . |
double |
doubleValueIn(IUnit targetUnit)
Get the numerical quantity value that this quantity would have if expressed in the unit
targetUnit , as a double . |
boolean |
equals(java.lang.Object other) |
float |
floatValue() |
ITypedQuantity<U> |
floorQuantize(ITypedQuantity<LinearUnit> quanta) |
int |
hashCode() |
int |
intValue() |
java.lang.String |
localizedFormat(boolean useBreakingSpace,
boolean allowCustomUnit) |
long |
longValue()
Get the numerical quantity value of this quantity as a
long . |
long |
longValueIn(IUnit targetUnit,
long maxAbsValue)
Get the numerical quantity value that this quantity would have if expressed in the unit
targetUnit , rounded to a mathematical integer, if that numerical value is in the
range [-maxAbsValue-1, maxAbsValue] . |
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. |
java.lang.Number |
numberValue()
Get the numerical quantity value that this quantity, as either a
Long or a
Number with at least the precision of double . |
java.lang.Number |
numberValueIn(IUnit targetUnit)
Get the numerical quantity value that this quantity would have if expressed in the unit
targetUnit , as either a Long or a Number with at least the precision
of double . |
java.lang.String |
persistableString()
A string representation independent of locale or internationalization, that when parsed using
KindOfQuantity.parsePersisted(String) (by this quantity's kind of quantity) yields a
value that is equal to this quantity. |
double |
ratioTo(IQuantity denominator)
Compute the ratio of this quantity to the given
consequent quantity, if both are of
the same linear kind. |
ITypedQuantity<LinearUnit> |
subtract(ITypedQuantity<U> subtrahend) |
protected ITypedQuantity<U> |
subtractLinear(ITypedQuantity<LinearUnit> subtrahend) |
java.lang.String |
toString() |
add, compareTo, displayUsing, getType, getUnit, in, in, interactiveFormat, interactiveFormat, isLinear, longValueIn, subtract
private static final long serialVersionUID
private final double numericalValue
protected DoubleStored(double numericalValue, U unit)
public int intValue()
intValue
in class java.lang.Number
public long longValue()
IQuantity
long
. This may cause
truncation and loss of precision.public float floatValue()
floatValue
in class java.lang.Number
public double doubleValue()
IQuantity
double
. This may cause loss of
precision.doubleValue
in interface IQuantity
doubleValue
in class java.lang.Number
double
public java.lang.Number numberValue()
IQuantity
Long
or a
Number
with at least the precision of double
.public long longValueIn(IUnit targetUnit, long maxAbsValue) throws QuantityConversionException
IQuantity
targetUnit
, rounded to a mathematical integer, if that numerical value is in the
range [-maxAbsValue-1, maxAbsValue]
. Otherwise, an
QuantityConversionException
will be thrown, with the violation encoded. Note that as
a result of this conversion, precision may be lost.long
QuantityConversionException
- if the result would be out of rangeIQuantity.numberValueIn(IUnit)
public long clampedLongValueIn(IUnit targetUnit)
IQuantity
long
value closest to the numerical quantity value that this quantity would
have if expressed in the unit targetUnit
. This means that values outside the range
[
Long.MIN_VALUE
,
Long.MAX_VALUE
]
will be clamped to
the closest extreme. Note that as a result of this conversion, precision may be lost.
This method is equivalent to IQuantity.in(IUnit)
@.
IQuantity.longValue()
, but is
preferred since it is both cheaper and its name more explicitly conveys the limitations
involved.
long
IQuantity.numberValueIn(IUnit)
public long clampedFloorIn(IUnit targetUnit)
IQuantity
long
value closest to the floor of the numerical quantity value that this
quantity would have if expressed in the unit targetUnit
. This means that values
outside the range[
Long.MIN_VALUE
,
Long.MAX_VALUE
]
will be clamped to the closest extreme. Note that as a result of this conversion, precision
may be lost.long
public int clampedIntFloorIn(IUnit targetUnit)
IQuantity
int
value closest to the floor of the numerical quantity value that this
quantity would have if expressed in the unit targetUnit
. This means that values
outside the range[
Integer.MIN_VALUE
,
Integer.MAX_VALUE
]
will be clamped to the closest extreme. Note that as a result of this conversion,
precision may be lost.int
public double doubleValueIn(IUnit targetUnit)
IQuantity
targetUnit
, as a double
. Note that as a result of this conversion, precision
may be lost.double
public java.lang.Number numberValueIn(IUnit targetUnit)
IQuantity
targetUnit
, as either a Long
or a Number
with at least the precision
of double
. If this quantity is exact, the unit conversion is known to be exact, and
the result can be exactly represented in a long
, a Long
will be returned.
Otherwise, some other Number
implementation, such as Double
will be returned.
Note that as a result of this conversion, precision may be lost.Long
if exact, otherwise as some other
Number
IQuantity.clampedLongValueIn(IUnit)
public ITypedQuantity<U> floorQuantize(ITypedQuantity<LinearUnit> quanta)
public java.lang.String persistableString()
IQuantity
KindOfQuantity.parsePersisted(String)
(by this quantity's kind of quantity) yields a
value that is equal
to this quantity. That is, the exact
representation must be preserved.public java.lang.String localizedFormat(boolean useBreakingSpace, boolean allowCustomUnit)
public int hashCode()
hashCode
in class ScalarQuantity<U extends TypedUnit<U>>
public boolean equals(java.lang.Object other)
equals
in class ScalarQuantity<U extends TypedUnit<U>>
public java.lang.String toString()
toString
in class java.lang.Object
public ITypedQuantity<U> add(ITypedQuantity<LinearUnit> addend) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
protected ITypedQuantity<U> subtractLinear(ITypedQuantity<LinearUnit> subtrahend)
subtractLinear
in class ScalarQuantity<U extends TypedUnit<U>>
public ITypedQuantity<LinearUnit> subtract(ITypedQuantity<U> subtrahend) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public ITypedQuantity<U> multiply(long factor) throws java.lang.UnsupportedOperationException
IQuantity
factor
, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException
will be thrown.factor
java.lang.UnsupportedOperationException
- if this quantity is not linearpublic ITypedQuantity<U> multiply(double factor) throws java.lang.UnsupportedOperationException
IQuantity
factor
, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException
will be thrown.factor
java.lang.UnsupportedOperationException
- if this quantity is not linearpublic double ratioTo(IQuantity denominator) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
IQuantity
consequent
quantity, if both are of
the same linear kind. Otherwise, this operation is undefined and an exception is thrown.consequent
, as a double
fractionjava.lang.UnsupportedOperationException
- if this quantity is not linearjava.lang.IllegalArgumentException
- if consequent
is not of a compatible kind of quantity