public final class RoundedMoney extends Object implements javax.money.MonetaryAmount, Comparable<javax.money.MonetaryAmount>, Serializable
MonetaryAmount based on
BigDecimal for the numeric representation.
As required by MonetaryAmount this class is final, thread-safe, immutable and
serializable.
| Modifier and Type | Field and Description |
|---|---|
static javax.money.MonetaryContext |
DEFAULT_MONETARY_CONTEXT
The default
MonetaryContext applied. |
| Constructor and Description |
|---|
RoundedMoney(Number number,
javax.money.CurrencyUnit currency,
MathContext mathContext) |
RoundedMoney(Number number,
javax.money.CurrencyUnit currency,
javax.money.MonetaryContext context,
javax.money.MonetaryOperator rounding) |
RoundedMoney(Number number,
javax.money.CurrencyUnit currency,
javax.money.MonetaryOperator rounding)
Creates a new instance os
RoundedMoney. |
| Modifier and Type | Method and Description |
|---|---|
RoundedMoney |
abs() |
RoundedMoney |
add(javax.money.MonetaryAmount amount) |
BigDecimal |
asNumberStripped()
Method that returns BigDecimal.ZERO, if
isZero(), and #number
stripTrailingZeros() in all other cases. |
<T> T |
asType(Class<T> type) |
<T> T |
asType(Class<T> type,
javax.money.MonetaryOperator adjuster) |
int |
compareTo(javax.money.MonetaryAmount o) |
RoundedMoney |
divide(double amount) |
RoundedMoney |
divide(long amount) |
RoundedMoney |
divide(Number divisor) |
RoundedMoney[] |
divideAndRemainder(double amount) |
RoundedMoney[] |
divideAndRemainder(long amount) |
RoundedMoney[] |
divideAndRemainder(Number divisor) |
RoundedMoney |
divideToIntegralValue(double divisor) |
RoundedMoney |
divideToIntegralValue(long divisor) |
RoundedMoney |
divideToIntegralValue(Number divisor) |
boolean |
equals(Object obj) |
static RoundedMoney |
from(javax.money.MonetaryAmount amt) |
javax.money.MonetaryContext |
getContext()
Access the
MathContext used by this instance. |
javax.money.CurrencyUnit |
getCurrency() |
javax.money.MonetaryAmountFactory<RoundedMoney> |
getFactory() |
javax.money.NumberValue |
getNumber() |
int |
getPrecision() |
int |
getScale() |
int |
hashCode() |
boolean |
isEqualTo(javax.money.MonetaryAmount amount) |
boolean |
isGreaterThan(javax.money.MonetaryAmount amount) |
boolean |
isGreaterThanOrEqualTo(javax.money.MonetaryAmount amount) |
boolean |
isLessThan(javax.money.MonetaryAmount amount) |
boolean |
isLessThanOrEqualTo(javax.money.MonetaryAmount amount) |
boolean |
isNegative() |
boolean |
isNegativeOrZero() |
boolean |
isNotEqualTo(javax.money.MonetaryAmount amount) |
boolean |
isPositive() |
boolean |
isPositiveOrZero() |
boolean |
isZero() |
RoundedMoney |
multiply(double amount) |
RoundedMoney |
multiply(long amount) |
RoundedMoney |
multiply(Number multiplicand) |
RoundedMoney |
negate() |
static RoundedMoney |
of(BigDecimal number,
javax.money.CurrencyUnit currency)
Translates a
BigDecimal value and a CurrencyUnit currency into a
Money. |
static RoundedMoney |
of(BigDecimal number,
javax.money.CurrencyUnit currency,
MathContext mathContext)
Translates a
BigDecimal value and a CurrencyUnit currency into a
Money. |
static RoundedMoney |
of(BigDecimal number,
javax.money.CurrencyUnit currency,
javax.money.MonetaryOperator rounding)
Translates a
BigDecimal value and a CurrencyUnit currency into a
Money. |
static RoundedMoney |
of(javax.money.CurrencyUnit currency,
Number number,
javax.money.MonetaryContext monetaryContext,
javax.money.MonetaryOperator rounding)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
javax.money.CurrencyUnit currency)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
javax.money.CurrencyUnit currency,
javax.money.MonetaryContext monetaryContext)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
javax.money.CurrencyUnit currency,
javax.money.MonetaryOperator rounding)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
String currencyCode)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
String currencyCode,
javax.money.MonetaryContext monetaryContext)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(Number number,
String currencyCode,
javax.money.MonetaryOperator rounding)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
of(String currencyCode,
Number number,
javax.money.MonetaryContext monetaryContext,
javax.money.MonetaryOperator rounding)
Static factory method for creating a new instance of
RoundedMoney . |
static RoundedMoney |
parse(CharSequence text)
Obtains an instance of RoundedMoney from a text string such as 'EUR
25.25'.
|
static RoundedMoney |
parse(CharSequence text,
javax.money.format.MonetaryAmountFormat formatter)
Obtains an instance of FastMoney from a text using specific formatter.
|
RoundedMoney |
plus() |
RoundedMoney |
pow(int n) |
<T> T |
query(javax.money.MonetaryQuery<T> query) |
RoundedMoney |
remainder(double amount) |
RoundedMoney |
remainder(long amount) |
RoundedMoney |
remainder(Number divisor) |
RoundedMoney |
scaleByPowerOfTen(int n) |
int |
signum() |
RoundedMoney |
stripTrailingZeros() |
RoundedMoney |
subtract(javax.money.MonetaryAmount subtrahend) |
String |
toString() |
RoundedMoney |
ulp() |
RoundedMoney |
with(javax.money.CurrencyUnit currency)
Creates a new Money instance, by just replacing the
CurrencyUnit. |
RoundedMoney |
with(javax.money.CurrencyUnit currency,
Number amount) |
RoundedMoney |
with(javax.money.MonetaryOperator operator) |
RoundedMoney |
with(Number amount) |
public static final javax.money.MonetaryContext DEFAULT_MONETARY_CONTEXT
MonetaryContext applied.public RoundedMoney(Number number, javax.money.CurrencyUnit currency, javax.money.MonetaryOperator rounding)
RoundedMoney.currency - the currency, not null.number - the amount, not null.public RoundedMoney(Number number, javax.money.CurrencyUnit currency, MathContext mathContext)
public RoundedMoney(Number number, javax.money.CurrencyUnit currency, javax.money.MonetaryContext context, javax.money.MonetaryOperator rounding)
public static RoundedMoney of(BigDecimal number, javax.money.CurrencyUnit currency)
BigDecimal value and a CurrencyUnit currency into a
Money.number - numeric value of the Money.currency - currency unit of the Money.Money combining the numeric value and currency unit.public static RoundedMoney of(BigDecimal number, javax.money.CurrencyUnit currency, javax.money.MonetaryOperator rounding)
BigDecimal value and a CurrencyUnit currency into a
Money.number - numeric value of the Money.currency - currency unit of the Money.rounding - The rounding to be applied.Money combining the numeric value and currency unit.public static RoundedMoney of(BigDecimal number, javax.money.CurrencyUnit currency, MathContext mathContext)
BigDecimal value and a CurrencyUnit currency into a
Money.number - numeric value of the Money.currency - currency unit of the Money.mathContext - the MathContext to be used.Money combining the numeric value and currency unit.public static RoundedMoney of(Number number, javax.money.CurrencyUnit currency)
RoundedMoney .currency - The target currency, not null.number - The numeric part, not null.RoundedMoney.public static RoundedMoney of(Number number, javax.money.CurrencyUnit currency, javax.money.MonetaryOperator rounding)
RoundedMoney .currency - The target currency, not null.number - The numeric part, not null.rounding - The rounding to be applied.RoundedMoney.public static RoundedMoney of(Number number, javax.money.CurrencyUnit currency, javax.money.MonetaryContext monetaryContext)
RoundedMoney .currency - The target currency, not null.number - The numeric part, not null.RoundedMoney.public static RoundedMoney of(javax.money.CurrencyUnit currency, Number number, javax.money.MonetaryContext monetaryContext, javax.money.MonetaryOperator rounding)
RoundedMoney .currency - The target currency, not null.number - The numeric part, not null.monetaryContext - the MonetaryContext to be used.rounding - The rounding to be applied.RoundedMoney.public static RoundedMoney of(Number number, String currencyCode)
RoundedMoney .currencyCode - The target currency as ISO currency code.number - The numeric part, not null.RoundedMoney.public static RoundedMoney of(Number number, String currencyCode, javax.money.MonetaryOperator rounding)
RoundedMoney .currencyCode - The target currency as ISO currency code.number - The numeric part, not null.rounding - The rounding to be applied.RoundedMoney.public static RoundedMoney of(Number number, String currencyCode, javax.money.MonetaryContext monetaryContext)
RoundedMoney .currencyCode - The target currency as ISO currency code.number - The numeric part, not null.RoundedMoney.public static RoundedMoney of(String currencyCode, Number number, javax.money.MonetaryContext monetaryContext, javax.money.MonetaryOperator rounding)
RoundedMoney .currencyCode - The target currency as ISO currency code.number - The numeric part, not null.rounding - The rounding to be applied.RoundedMoney.public javax.money.CurrencyUnit getCurrency()
getCurrency in interface javax.money.CurrencySupplierpublic javax.money.MonetaryContext getContext()
MathContext used by this instance.getContext in interface javax.money.MonetaryAmountMathContext used, never null.public RoundedMoney abs()
abs in interface javax.money.MonetaryAmountpublic RoundedMoney add(javax.money.MonetaryAmount amount)
add in interface javax.money.MonetaryAmountpublic RoundedMoney divide(Number divisor)
divide in interface javax.money.MonetaryAmountpublic RoundedMoney[] divideAndRemainder(Number divisor)
divideAndRemainder in interface javax.money.MonetaryAmountpublic RoundedMoney divideToIntegralValue(Number divisor)
divideToIntegralValue in interface javax.money.MonetaryAmountpublic RoundedMoney multiply(Number multiplicand)
multiply in interface javax.money.MonetaryAmountpublic RoundedMoney negate()
negate in interface javax.money.MonetaryAmountpublic RoundedMoney plus()
plus in interface javax.money.MonetaryAmountpublic RoundedMoney subtract(javax.money.MonetaryAmount subtrahend)
subtract in interface javax.money.MonetaryAmountpublic RoundedMoney pow(int n)
public RoundedMoney ulp()
public RoundedMoney remainder(Number divisor)
remainder in interface javax.money.MonetaryAmountpublic RoundedMoney scaleByPowerOfTen(int n)
scaleByPowerOfTen in interface javax.money.MonetaryAmountpublic boolean isZero()
isZero in interface javax.money.MonetaryAmountpublic boolean isPositive()
isPositive in interface javax.money.MonetaryAmountpublic boolean isPositiveOrZero()
isPositiveOrZero in interface javax.money.MonetaryAmountpublic boolean isNegative()
isNegative in interface javax.money.MonetaryAmountpublic boolean isNegativeOrZero()
isNegativeOrZero in interface javax.money.MonetaryAmountpublic RoundedMoney with(Number amount)
public RoundedMoney with(javax.money.CurrencyUnit currency)
CurrencyUnit.currency - the currency unit to be replaced, not nullMathContext, but the new
CurrencyUnit.public RoundedMoney with(javax.money.CurrencyUnit currency, Number amount)
public int getScale()
public int getPrecision()
public int signum()
signum in interface javax.money.MonetaryAmountpublic boolean isLessThan(javax.money.MonetaryAmount amount)
isLessThan in interface javax.money.MonetaryAmountpublic boolean isLessThanOrEqualTo(javax.money.MonetaryAmount amount)
isLessThanOrEqualTo in interface javax.money.MonetaryAmountpublic boolean isGreaterThan(javax.money.MonetaryAmount amount)
isGreaterThan in interface javax.money.MonetaryAmountpublic boolean isGreaterThanOrEqualTo(javax.money.MonetaryAmount amount)
isGreaterThanOrEqualTo in interface javax.money.MonetaryAmountpublic boolean isEqualTo(javax.money.MonetaryAmount amount)
isEqualTo in interface javax.money.MonetaryAmountpublic boolean isNotEqualTo(javax.money.MonetaryAmount amount)
public RoundedMoney with(javax.money.MonetaryOperator operator)
with in interface javax.money.MonetaryAmountpublic static RoundedMoney from(javax.money.MonetaryAmount amt)
public static RoundedMoney parse(CharSequence text)
text - the input text, not null.NullPointerExceptionNumberFormatExceptionjavax.money.UnknownCurrencyExceptionpublic static RoundedMoney parse(CharSequence text, javax.money.format.MonetaryAmountFormat formatter)
text - the text to parse not nullformatter - the formatter to use not nullpublic <T> T query(javax.money.MonetaryQuery<T> query)
query in interface javax.money.MonetaryAmountpublic int compareTo(javax.money.MonetaryAmount o)
compareTo in interface Comparable<javax.money.MonetaryAmount>public javax.money.NumberValue getNumber()
getNumber in interface javax.money.NumberSupplierpublic BigDecimal asNumberStripped()
isZero(), and #number
stripTrailingZeros() in all other cases.public RoundedMoney multiply(long amount)
multiply in interface javax.money.MonetaryAmountpublic RoundedMoney multiply(double amount)
multiply in interface javax.money.MonetaryAmountpublic RoundedMoney divide(long amount)
divide in interface javax.money.MonetaryAmountpublic RoundedMoney divide(double amount)
divide in interface javax.money.MonetaryAmountpublic RoundedMoney remainder(long amount)
remainder in interface javax.money.MonetaryAmountpublic RoundedMoney remainder(double amount)
remainder in interface javax.money.MonetaryAmountpublic RoundedMoney[] divideAndRemainder(long amount)
divideAndRemainder in interface javax.money.MonetaryAmountpublic RoundedMoney[] divideAndRemainder(double amount)
divideAndRemainder in interface javax.money.MonetaryAmountpublic RoundedMoney stripTrailingZeros()
stripTrailingZeros in interface javax.money.MonetaryAmountpublic RoundedMoney divideToIntegralValue(long divisor)
divideToIntegralValue in interface javax.money.MonetaryAmountpublic RoundedMoney divideToIntegralValue(double divisor)
divideToIntegralValue in interface javax.money.MonetaryAmountpublic javax.money.MonetaryAmountFactory<RoundedMoney> getFactory()
getFactory in interface javax.money.MonetaryAmountCopyright © 2012-2015 JavaMoney. All Rights Reserved.