public static class ScalarQuantity.LongStored<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 long |
numericalValue |
private static long |
serialVersionUID |
unitAUTO, EXACT, VERBOSE| Modifier | Constructor and Description |
|---|---|
protected |
LongStored(long 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. |
int |
compareTo(IQuantity other) |
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, displayUsing, getType, getUnit, in, in, interactiveFormat, interactiveFormat, isLinear, longValueIn, subtractprivate static final long serialVersionUID
private final long numericalValue
protected LongStored(long numericalValue,
U unit)
public int intValue()
intValue in class java.lang.Numberpublic long longValue()
IQuantitylong. This may cause
truncation and loss of precision.public float floatValue()
floatValue in class java.lang.Numberpublic double doubleValue()
IQuantitydouble. This may cause loss of
precision.doubleValue in interface IQuantitydoubleValue in class java.lang.Numberdoublepublic java.lang.Number numberValue()
IQuantityLong or a
Number with at least the precision of double.public long longValueIn(IUnit targetUnit, long maxAbsValue) throws QuantityConversionException
IQuantitytargetUnit, 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.longQuantityConversionException - if the result would be out of rangeIQuantity.numberValueIn(IUnit)public long clampedLongValueIn(IUnit targetUnit)
IQuantitylong 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.
longIQuantity.numberValueIn(IUnit)public long clampedFloorIn(IUnit targetUnit)
IQuantitylong 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.longpublic int clampedIntFloorIn(IUnit targetUnit)
IQuantityint 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.intpublic double doubleValueIn(IUnit targetUnit)
IQuantitytargetUnit, as a double. Note that as a result of this conversion, precision
may be lost.doublepublic java.lang.Number numberValueIn(IUnit targetUnit)
IQuantitytargetUnit, 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
NumberIQuantity.clampedLongValueIn(IUnit)public ITypedQuantity<U> floorQuantize(ITypedQuantity<LinearUnit> quanta)
public java.lang.String persistableString()
IQuantityKindOfQuantity.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 int compareTo(IQuantity other)
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.Objectpublic ITypedQuantity<U> add(ITypedQuantity<LinearUnit> addend) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionprotected 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.IllegalArgumentExceptionpublic ITypedQuantity<U> multiply(long factor) throws java.lang.UnsupportedOperationException
IQuantityfactor, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException will be thrown.factorjava.lang.UnsupportedOperationException - if this quantity is not linearpublic ITypedQuantity<U> multiply(double factor) throws java.lang.UnsupportedOperationException
IQuantityfactor, if this is a
linear quantity. Otherwise, this operation is undefined and
UnsupportedOperationException will be thrown.factorjava.lang.UnsupportedOperationException - if this quantity is not linearpublic double ratioTo(IQuantity denominator) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
IQuantityconsequent 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