Package org.openjdk.jmc.common.unit
Class ScalarQuantity.LongStored<U extends TypedUnit<U>>
- java.lang.Object
-
- java.lang.Number
-
- org.openjdk.jmc.common.unit.ScalarQuantity<U>
-
- org.openjdk.jmc.common.unit.ScalarQuantity.LongStored<U>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<IQuantity>,IDisplayable,IItem,IQuantity,ITypedQuantity<U>
- Enclosing class:
- ScalarQuantity<U extends TypedUnit<U>>
public static class ScalarQuantity.LongStored<U extends TypedUnit<U>> extends ScalarQuantity<U>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openjdk.jmc.common.unit.ScalarQuantity
ScalarQuantity.DoubleStored<U extends TypedUnit<U>>, ScalarQuantity.LongStored<U extends TypedUnit<U>>
-
-
Field Summary
Fields Modifier and Type Field Description private longnumericalValueprivate static longserialVersionUID-
Fields inherited from class org.openjdk.jmc.common.unit.ScalarQuantity
unit
-
Fields inherited from interface org.openjdk.jmc.common.IDisplayable
AUTO, EXACT, VERBOSE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLongStored(long numericalValue, U unit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ITypedQuantity<U>add(ITypedQuantity<LinearUnit> addend)longclampedFloorIn(IUnit targetUnit)Get thelongvalue closest to the floor of the numerical quantity value that this quantity would have if expressed in the unittargetUnit.intclampedIntFloorIn(IUnit targetUnit)Get theintvalue closest to the floor of the numerical quantity value that this quantity would have if expressed in the unittargetUnit.longclampedLongValueIn(IUnit targetUnit)Get thelongvalue closest to the numerical quantity value that this quantity would have if expressed in the unittargetUnit.intcompareTo(IQuantity other)doubledoubleValue()Get the numerical quantity value of this quantity as adouble.doubledoubleValueIn(IUnit targetUnit)Get the numerical quantity value that this quantity would have if expressed in the unittargetUnit, as adouble.booleanequals(java.lang.Object other)floatfloatValue()ITypedQuantity<U>floorQuantize(ITypedQuantity<LinearUnit> quanta)inthashCode()intintValue()java.lang.StringlocalizedFormat(boolean useBreakingSpace, boolean allowCustomUnit)longlongValue()Get the numerical quantity value of this quantity as along.longlongValueIn(IUnit targetUnit, long maxAbsValue)Get the numerical quantity value that this quantity would have if expressed in the unittargetUnit, 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 withfactor, if this is a linear quantity.ITypedQuantity<U>multiply(long factor)Returns a new quantity that is this quantity multiplied withfactor, if this is a linear quantity.java.lang.NumbernumberValue()Get the numerical quantity value that this quantity, as either aLongor aNumberwith at least the precision ofdouble.java.lang.NumbernumberValueIn(IUnit targetUnit)Get the numerical quantity value that this quantity would have if expressed in the unittargetUnit, as either aLongor aNumberwith at least the precision ofdouble.java.lang.StringpersistableString()A string representation independent of locale or internationalization, that when parsed usingKindOfQuantity.parsePersisted(String)(by this quantity's kind of quantity) yields a value that isequalto this quantity.doubleratioTo(IQuantity denominator)Compute the ratio of this quantity to the givenconsequentquantity, if both are of the same linear kind.ITypedQuantity<LinearUnit>subtract(ITypedQuantity<U> subtrahend)protected ITypedQuantity<U>subtractLinear(ITypedQuantity<LinearUnit> subtrahend)java.lang.StringtoString()-
Methods inherited from class org.openjdk.jmc.common.unit.ScalarQuantity
add, displayUsing, getType, getUnit, in, in, interactiveFormat, interactiveFormat, isLinear, longValueIn, subtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
numericalValue
private final long numericalValue
-
-
Constructor Detail
-
LongStored
protected LongStored(long numericalValue, U unit)
-
-
Method Detail
-
intValue
public int intValue()
- Specified by:
intValuein classjava.lang.Number
-
longValue
public long longValue()
Description copied from interface:IQuantityGet the numerical quantity value of this quantity as along. This may cause truncation and loss of precision.
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
doubleValue
public double doubleValue()
Description copied from interface:IQuantityGet the numerical quantity value of this quantity as adouble. This may cause loss of precision.- Specified by:
doubleValuein interfaceIQuantity- Specified by:
doubleValuein classjava.lang.Number- Returns:
- the numerical quantity, as a
double
-
numberValue
public java.lang.Number numberValue()
Description copied from interface:IQuantityGet the numerical quantity value that this quantity, as either aLongor aNumberwith at least the precision ofdouble.- Returns:
- the numerical quantity
-
longValueIn
public long longValueIn(IUnit targetUnit, long maxAbsValue) throws QuantityConversionException
Description copied from interface:IQuantityGet the numerical quantity value that this quantity would have if expressed in the unittargetUnit, rounded to a mathematical integer, if that numerical value is in the range[-maxAbsValue-1, maxAbsValue]. Otherwise, anQuantityConversionExceptionwill be thrown, with the violation encoded. Note that as a result of this conversion, precision may be lost.- Returns:
- the numerical quantity, as a
long - Throws:
QuantityConversionException- if the result would be out of range- See Also:
IQuantity.numberValueIn(IUnit)
-
clampedLongValueIn
public long clampedLongValueIn(IUnit targetUnit)
Description copied from interface:IQuantityGet thelongvalue closest to the numerical quantity value that this quantity would have if expressed in the unittargetUnit. 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.- Returns:
- the numerical quantity, as a
long - See Also:
IQuantity.numberValueIn(IUnit)
-
clampedFloorIn
public long clampedFloorIn(IUnit targetUnit)
Description copied from interface:IQuantityGet thelongvalue closest to the floor of the numerical quantity value that this quantity would have if expressed in the unittargetUnit. 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.- Returns:
- the floor of the numerical quantity, as a
long
-
clampedIntFloorIn
public int clampedIntFloorIn(IUnit targetUnit)
Description copied from interface:IQuantityGet theintvalue closest to the floor of the numerical quantity value that this quantity would have if expressed in the unittargetUnit. 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.- Returns:
- the floor of the numerical quantity, as an
int
-
doubleValueIn
public double doubleValueIn(IUnit targetUnit)
Description copied from interface:IQuantityGet the numerical quantity value that this quantity would have if expressed in the unittargetUnit, as adouble. Note that as a result of this conversion, precision may be lost.- Returns:
- the numerical quantity, as a
double
-
numberValueIn
public java.lang.Number numberValueIn(IUnit targetUnit)
Description copied from interface:IQuantityGet the numerical quantity value that this quantity would have if expressed in the unittargetUnit, as either aLongor aNumberwith at least the precision ofdouble. If this quantity is exact, the unit conversion is known to be exact, and the result can be exactly represented in along, aLongwill be returned. Otherwise, some otherNumberimplementation, such asDoublewill be returned. Note that as a result of this conversion, precision may be lost.- Returns:
- the numerical quantity, as a
Longif exact, otherwise as some otherNumber - See Also:
IQuantity.clampedLongValueIn(IUnit)
-
floorQuantize
public ITypedQuantity<U> floorQuantize(ITypedQuantity<LinearUnit> quanta)
-
persistableString
public java.lang.String persistableString()
Description copied from interface:IQuantityA string representation independent of locale or internationalization, that when parsed usingKindOfQuantity.parsePersisted(String)(by this quantity's kind of quantity) yields a value that isequalto this quantity. That is, the exact representation must be preserved.- Returns:
- a string representation independent of locale or internationalization.
-
localizedFormat
public java.lang.String localizedFormat(boolean useBreakingSpace, boolean allowCustomUnit)
-
hashCode
public int hashCode()
- Specified by:
hashCodein classScalarQuantity<U extends TypedUnit<U>>
-
compareTo
public int compareTo(IQuantity other)
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equalsin classScalarQuantity<U extends TypedUnit<U>>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
add
public ITypedQuantity<U> add(ITypedQuantity<LinearUnit> addend) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
subtractLinear
protected ITypedQuantity<U> subtractLinear(ITypedQuantity<LinearUnit> subtrahend)
- Specified by:
subtractLinearin classScalarQuantity<U extends TypedUnit<U>>
-
subtract
public ITypedQuantity<LinearUnit> subtract(ITypedQuantity<U> subtrahend) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
multiply
public ITypedQuantity<U> multiply(long factor) throws java.lang.UnsupportedOperationException
Description copied from interface:IQuantityReturns a new quantity that is this quantity multiplied withfactor, if this is a linear quantity. Otherwise, this operation is undefined andUnsupportedOperationExceptionwill be thrown.- Returns:
- this quantity multiplied with
factor - Throws:
java.lang.UnsupportedOperationException- if this quantity is not linear
-
multiply
public ITypedQuantity<U> multiply(double factor) throws java.lang.UnsupportedOperationException
Description copied from interface:IQuantityReturns a new quantity that is this quantity multiplied withfactor, if this is a linear quantity. Otherwise, this operation is undefined andUnsupportedOperationExceptionwill be thrown.- Returns:
- this quantity multiplied with
factor - Throws:
java.lang.UnsupportedOperationException- if this quantity is not linear
-
ratioTo
public double ratioTo(IQuantity denominator) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
Description copied from interface:IQuantityCompute the ratio of this quantity to the givenconsequentquantity, if both are of the same linear kind. Otherwise, this operation is undefined and an exception is thrown.- Returns:
- the ratio of this quantity to
consequent, as adoublefraction - Throws:
java.lang.UnsupportedOperationException- if this quantity is not linearjava.lang.IllegalArgumentException- ifconsequentis not of a compatible kind of quantity
-
-