Class OceanusPrice
java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney
io.github.tonywasher.joceanus.oceanus.decimal.OceanusPrice
- All Implemented Interfaces:
Comparable<OceanusDecimal>
Represents a Price object.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intAdditional number of decimals for Price.Fields inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney
BYTE_LEN, DEFAULT_CURRENCY, ERROR_DIFFERFields inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
MAX_DECIMALS, RADIX_TEN -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for price of value zero in the default currency.OceanusPrice(byte[] pBuffer) Create the price from a byte array.OceanusPrice(OceanusPrice pPrice) Construct a new Price by copying another price.OceanusPrice(String pSource) Constructor for price from a decimal string.OceanusPrice(String pSource, Currency pCurrency) Constructor for price from a decimal string.OceanusPrice(Currency pCurrency) Constructor for money of value zero in specified currency. -
Method Summary
Modifier and TypeMethodDescriptionchangeCurrency(Currency pCurrency) Obtain value in different currency.convertCurrency(Currency pCurrency, OceanusRatio pRate) Obtain converted money.static OceanusPricegetWholeUnits(long pUnits) Factory method for generating whole monetary units (e.g. £)static OceanusPricegetWholeUnits(long pUnits, Currency pCurrency) Factory method for generating whole monetary units for a currency (e.g. £)voidsubtractPrice(OceanusPrice pValue) Subtract a monetary price from the value.Methods inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney
addAmount, addValue, equals, getCurrency, getDefaultCurrency, getDilutedMoney, grossValueAtRate, hashCode, subtractAmount, subtractValue, taxCreditAtRate, toBytes, valueAtRate, valueAtRatio, valueAtWeight, valueAtWeightMethods inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
add, adjustDecimals, adjustToScale, byteValue, byteValueExact, calculateProduct, calculateQuotient, calculateSafeQuotient, checkFractionalZero, compareTo, divide, divide, divideToIntegralValue, doubleValue, floatValue, getFactor, 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, toString, unscaledValue
-
Field Details
-
XTRA_DECIMALS
static final int XTRA_DECIMALSAdditional number of decimals for Price.- See Also:
-
-
Constructor Details
-
OceanusPrice
public OceanusPrice()Constructor for price of value zero in the default currency. -
OceanusPrice
Constructor for money of value zero in specified currency.- Parameters:
pCurrency- the currency
-
OceanusPrice
Construct a new Price by copying another price.- Parameters:
pPrice- the Price to copy
-
OceanusPrice
Constructor for price from a decimal string.- Parameters:
pSource- The source decimal string- Throws:
IllegalArgumentException- on invalidly formatted argument
-
OceanusPrice
Constructor for price from a decimal string.- Parameters:
pSource- The source decimal stringpCurrency- the currency- Throws:
IllegalArgumentException- on invalidly formatted argument
-
OceanusPrice
public OceanusPrice(byte[] pBuffer) Create the price from a byte array.- Parameters:
pBuffer- the buffer
-
-
Method Details
-
getWholeUnits
Factory method for generating whole monetary units for a currency (e.g. £)- Parameters:
pUnits- the number of whole monetary unitspCurrency- the currency- Returns:
- the allocated price
-
getWholeUnits
Factory method for generating whole monetary units (e.g. £)- Parameters:
pUnits- the number of whole monetary units- Returns:
- the allocated price
-
changeCurrency
Description copied from class:OceanusMoneyObtain value in different currency.- Overrides:
changeCurrencyin classOceanusMoney- Parameters:
pCurrency- the currency to convert to- Returns:
- the converted money in the new currency
-
convertCurrency
Description copied from class:OceanusMoneyObtain converted money.- Overrides:
convertCurrencyin classOceanusMoney- Parameters:
pCurrency- the currency to convert topRate- the conversion rate- Returns:
- the converted money in the new currency
-
subtractPrice
Subtract a monetary price from the value.- Parameters:
pValue- The money to subtract from this one.
-