public final class RoundedMoney extends Object implements javax.money.MonetaryAmount, Comparable<RoundedMoney>, 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 MathContext |
DEFAULT_MATH_CONTEXT |
Modifier and Type | Method and Description |
---|---|
RoundedMoney |
abs() |
RoundedMoney |
add(RoundedMoney amount) |
Number |
asNumber() |
<T> T |
asType(Class<T> type) |
<T> T |
asType(Class<T> type,
javax.money.MonetaryAdjuster adjuster) |
int |
compareTo(RoundedMoney o) |
RoundedMoney |
divide(Number divisor) |
RoundedMoney |
divide(RoundedMoney divisor) |
RoundedMoney[] |
divideAndRemainder(javax.money.MonetaryAmount divisor) |
RoundedMoney[] |
divideAndRemainder(Number divisor) |
RoundedMoney |
divideToIntegralValue(javax.money.MonetaryAmount divisor) |
RoundedMoney |
divideToIntegralValue(Number divisor) |
double |
doubleValue() |
boolean |
equals(Object obj) |
long |
getAmountFractionDenominator() |
long |
getAmountFractionNumerator() |
long |
getAmountWhole() |
javax.money.CurrencyUnit |
getCurrency() |
MathContext |
getMathContext()
Access the
MathContext used by this instance. |
Class<?> |
getNumberType() |
int |
getPrecision() |
int |
getScale() |
int |
hashCode() |
boolean |
isEqualTo(RoundedMoney amount) |
boolean |
isGreaterThan(RoundedMoney amount) |
boolean |
isGreaterThanOrEqualTo(RoundedMoney amount) |
boolean |
isLessThan(RoundedMoney amount) |
boolean |
isLessThanOrEqualTo(RoundedMoney amount) |
boolean |
isNegative() |
boolean |
isNegativeOrZero() |
boolean |
isNotEqualTo(RoundedMoney amount) |
boolean |
isPositive() |
boolean |
isPositiveOrZero() |
boolean |
isZero() |
long |
longValue() |
long |
longValueExact() |
RoundedMoney |
multiply(javax.money.MonetaryAmount multiplicand) |
RoundedMoney |
multiply(Number multiplicand) |
RoundedMoney |
negate() |
static RoundedMoney |
of(javax.money.CurrencyUnit currency,
BigDecimal number)
Translates a
BigDecimal value and a CurrencyUnit currency
into a Money . |
static RoundedMoney |
of(javax.money.CurrencyUnit currency,
BigDecimal number,
MathContext mathContext)
Translates a
BigDecimal value and a CurrencyUnit currency
into a Money . |
static RoundedMoney |
of(javax.money.CurrencyUnit currency,
Number number)
Static factory method for creating a new instance of
RoundedMoney
. |
static RoundedMoney |
of(javax.money.CurrencyUnit currency,
Number number,
MathContext mathContext)
Static factory method for creating a new instance of
RoundedMoney
. |
static RoundedMoney |
of(String currencyCode,
Number number)
Static factory method for creating a new instance of
RoundedMoney
. |
static RoundedMoney |
of(String currencyCode,
Number number,
MathContext mathContext)
Static factory method for creating a new instance of
RoundedMoney
. |
static RoundedMoney |
ofZero(javax.money.CurrencyUnit currency)
Factory method creating a zero instance with the given {@code currency);
|
static RoundedMoney |
ofZero(String currency)
Factory method creating a zero instance with the given {@code currency);
|
RoundedMoney |
plus() |
RoundedMoney |
pow(int n) |
<T> T |
query(javax.money.MonetaryQuery<T> function) |
RoundedMoney |
remainder(Number divisor) |
RoundedMoney |
remainder(RoundedMoney divisor) |
RoundedMoney |
scaleByPowerOfTen(int n) |
RoundedMoney |
setMathContext(MathContext mathContext)
Allows to change the
MathContext . |
int |
signum() |
RoundedMoney |
subtract(RoundedMoney subtrahend) |
String |
toEngineeringString() |
String |
toPlainString() |
String |
toString() |
RoundedMoney |
ulp() |
RoundedMoney |
with(javax.money.CurrencyUnit currency,
Number amount) |
RoundedMoney |
with(javax.money.MonetaryAdjuster operation) |
RoundedMoney |
with(Number amount) |
public static final MathContext DEFAULT_MATH_CONTEXT
public static RoundedMoney of(javax.money.CurrencyUnit currency, BigDecimal number)
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(javax.money.CurrencyUnit currency, BigDecimal number, 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(javax.money.CurrencyUnit currency, Number number)
RoundedMoney
.currency
- The target currency, not null.number
- The numeric part, not null.RoundedMoney
.public static RoundedMoney of(javax.money.CurrencyUnit currency, Number number, MathContext mathContext)
RoundedMoney
.currency
- The target currency, not null.number
- The numeric part, not null.RoundedMoney
.public static RoundedMoney of(String currencyCode, Number number)
RoundedMoney
.isoCurrencyCode
- The target currency as ISO currency code.number
- The numeric part, not null.RoundedMoney
.public static RoundedMoney of(String currencyCode, Number number, MathContext mathContext)
RoundedMoney
.isoCurrencyCode
- The target currency as ISO currency code.number
- The numeric part, not null.RoundedMoney
.public static RoundedMoney ofZero(javax.money.CurrencyUnit currency)
currency
- the target currency of the amount being created.public static RoundedMoney ofZero(String currency)
currency
- the target currency of the amount being created.public javax.money.CurrencyUnit getCurrency()
getCurrency
in interface javax.money.MonetaryAmount
public MathContext getMathContext()
MathContext
used by this instance.MathContext
used, never null.public RoundedMoney setMathContext(MathContext mathContext)
MathContext
. The context will used, on
subsequent operation, where feasible and also propagated to child results
of arithmetic calculations.mathContext
- The new MathContext
, not null.RoundedMoney
instance, with the new
MathContext
.public RoundedMoney abs()
public RoundedMoney add(RoundedMoney amount)
public RoundedMoney divide(RoundedMoney divisor)
public RoundedMoney divide(Number divisor)
public RoundedMoney[] divideAndRemainder(javax.money.MonetaryAmount divisor)
public RoundedMoney[] divideAndRemainder(Number divisor)
public RoundedMoney divideToIntegralValue(javax.money.MonetaryAmount divisor)
public RoundedMoney divideToIntegralValue(Number divisor)
public RoundedMoney multiply(javax.money.MonetaryAmount multiplicand)
public RoundedMoney multiply(Number multiplicand)
public RoundedMoney negate()
public RoundedMoney plus()
public RoundedMoney subtract(RoundedMoney subtrahend)
public RoundedMoney pow(int n)
public RoundedMoney ulp()
public RoundedMoney remainder(RoundedMoney divisor)
public RoundedMoney remainder(Number divisor)
public RoundedMoney scaleByPowerOfTen(int n)
public boolean isZero()
public boolean isPositive()
public boolean isPositiveOrZero()
public boolean isNegative()
public boolean isNegativeOrZero()
public RoundedMoney with(Number amount)
public RoundedMoney with(javax.money.CurrencyUnit currency, Number amount)
public int getScale()
public int getPrecision()
public long longValue()
public long longValueExact()
public double doubleValue()
public int signum()
public String toEngineeringString()
public String toPlainString()
public boolean isLessThan(RoundedMoney amount)
public boolean isLessThanOrEqualTo(RoundedMoney amount)
public boolean isGreaterThan(RoundedMoney amount)
public boolean isGreaterThanOrEqualTo(RoundedMoney amount)
public boolean isEqualTo(RoundedMoney amount)
public boolean isNotEqualTo(RoundedMoney amount)
public Class<?> getNumberType()
public RoundedMoney with(javax.money.MonetaryAdjuster operation)
with
in interface javax.money.MonetaryAmount
public <T> T query(javax.money.MonetaryQuery<T> function)
query
in interface javax.money.MonetaryAmount
public int compareTo(RoundedMoney o)
compareTo
in interface Comparable<RoundedMoney>
public long getAmountWhole()
getAmountWhole
in interface javax.money.MonetaryAmount
public long getAmountFractionNumerator()
getAmountFractionNumerator
in interface javax.money.MonetaryAmount
public long getAmountFractionDenominator()
getAmountFractionDenominator
in interface javax.money.MonetaryAmount
Copyright © 2012–2013 JSR 354 - Expert Group. All rights reserved.