Class OceanusUnits
java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
io.github.tonywasher.joceanus.oceanus.decimal.OceanusUnits
- All Implemented Interfaces:
Comparable<OceanusDecimal>
Represents a Units object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intStandard number of decimals for Units.Fields inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
BYTE_LEN, MAX_DECIMALS, RADIX_TEN -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new Units.OceanusUnits(byte[] pBuffer) Create the units from a byte array.OceanusUnits(OceanusUnits pUnits) Construct a new Units by copying another units.OceanusUnits(String pSource) Constructor for units from a decimal string. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUnits(OceanusUnits pValue) Add units to the value.voidaddValue(OceanusDecimal pValue) Add a Decimal to the value.static OceanusUnitsgetWholeUnits(long pValue) Construct a new Units by setting the value explicitly.voidsubtractUnits(OceanusUnits pValue) Subtract units from the value.voidsubtractValue(OceanusDecimal pValue) Subtract a Decimal from the value.valueAtPrice(OceanusPrice pPrice) calculate the value of these units at a given price.Methods inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
add, adjustDecimals, adjustToScale, byteValue, byteValueExact, calculateProduct, calculateQuotient, calculateSafeQuotient, checkFractionalZero, compareTo, divide, divide, divideToIntegralValue, doubleValue, equals, floatValue, getFactor, hashCode, intValue, intValueExact, isNonZero, isPositive, isZero, longValue, longValueExact, max, min, movePointLeft, movePointRight, multiply, multiply, negate, recordScale, reduceScale, remainder, scale, setValue, setZero, shortValue, shortValueExact, signum, subtract, toBigDecimal, toBigInteger, toBigIntegerExact, toBytes, toString, unscaledValue
-
Field Details
-
NUM_DECIMALS
protected static final int NUM_DECIMALSStandard number of decimals for Units.- See Also:
-
-
Constructor Details
-
OceanusUnits
public OceanusUnits()Construct a new Units. -
OceanusUnits
Construct a new Units by copying another units.- Parameters:
pUnits- the Units to copy
-
OceanusUnits
Constructor for units from a decimal string.- Parameters:
pSource- The source decimal string- Throws:
IllegalArgumentException- on invalidly formatted argument
-
OceanusUnits
public OceanusUnits(byte[] pBuffer) Create the units from a byte array.- Parameters:
pBuffer- the buffer
-
-
Method Details
-
getWholeUnits
Construct a new Units by setting the value explicitly.- Parameters:
pValue- the unscaled value- Returns:
- the new Rate
-
addUnits
Add units to the value.- Parameters:
pValue- The units to add to this one.
-
subtractUnits
Subtract units from the value.- Parameters:
pValue- The units to subtract from this one.
-
addValue
Description copied from class:OceanusDecimalAdd a Decimal to the value. The value of this Decimal is updated and the scale is maintained.- Overrides:
addValuein classOceanusDecimal- Parameters:
pValue- The Decimal to add to this one.
-
subtractValue
Description copied from class:OceanusDecimalSubtract a Decimal from the value. The value of this Decimal is updated and the scale is maintained.- Overrides:
subtractValuein classOceanusDecimal- Parameters:
pValue- The decimal to subtract from this one.
-
valueAtPrice
calculate the value of these units at a given price.- Parameters:
pPrice- the per unit price- Returns:
- the calculated value
-