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 divisor) |
RoundedMoney |
divide(long divisor) |
RoundedMoney |
divide(Number divisor) |
RoundedMoney[] |
divideAndRemainder(double divisor) |
RoundedMoney[] |
divideAndRemainder(long divisor) |
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 multiplicand) |
RoundedMoney |
multiply(long multiplicand) |
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 divisor) |
RoundedMoney |
remainder(long divisor) |
RoundedMoney |
remainder(Number divisor) |
RoundedMoney |
scaleByPowerOfTen(int power) |
int |
signum() |
RoundedMoney |
stripTrailingZeros() |
RoundedMoney |
subtract(javax.money.MonetaryAmount amount) |
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.CurrencySupplier
public javax.money.MonetaryContext getContext()
MathContext
used by this instance.getContext
in interface javax.money.MonetaryAmount
MathContext
used, never null.public RoundedMoney abs()
abs
in interface javax.money.MonetaryAmount
public RoundedMoney add(javax.money.MonetaryAmount amount)
add
in interface javax.money.MonetaryAmount
public RoundedMoney divide(Number divisor)
divide
in interface javax.money.MonetaryAmount
public RoundedMoney[] divideAndRemainder(Number divisor)
divideAndRemainder
in interface javax.money.MonetaryAmount
public RoundedMoney divideToIntegralValue(Number divisor)
divideToIntegralValue
in interface javax.money.MonetaryAmount
public RoundedMoney multiply(Number multiplicand)
multiply
in interface javax.money.MonetaryAmount
public RoundedMoney negate()
negate
in interface javax.money.MonetaryAmount
public RoundedMoney plus()
plus
in interface javax.money.MonetaryAmount
public RoundedMoney subtract(javax.money.MonetaryAmount amount)
subtract
in interface javax.money.MonetaryAmount
public RoundedMoney pow(int n)
public RoundedMoney ulp()
public RoundedMoney remainder(Number divisor)
remainder
in interface javax.money.MonetaryAmount
public RoundedMoney scaleByPowerOfTen(int power)
scaleByPowerOfTen
in interface javax.money.MonetaryAmount
public boolean isZero()
isZero
in interface javax.money.MonetaryAmount
public boolean isPositive()
isPositive
in interface javax.money.MonetaryAmount
public boolean isPositiveOrZero()
isPositiveOrZero
in interface javax.money.MonetaryAmount
public boolean isNegative()
isNegative
in interface javax.money.MonetaryAmount
public boolean isNegativeOrZero()
isNegativeOrZero
in interface javax.money.MonetaryAmount
public RoundedMoney with(Number amount)
public RoundedMoney with(javax.money.CurrencyUnit currency)
CurrencyUnit
.currency
- the currency unit to be replaced, not null
MathContext
, 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.MonetaryAmount
public boolean isLessThan(javax.money.MonetaryAmount amount)
isLessThan
in interface javax.money.MonetaryAmount
public boolean isLessThanOrEqualTo(javax.money.MonetaryAmount amount)
isLessThanOrEqualTo
in interface javax.money.MonetaryAmount
public boolean isGreaterThan(javax.money.MonetaryAmount amount)
isGreaterThan
in interface javax.money.MonetaryAmount
public boolean isGreaterThanOrEqualTo(javax.money.MonetaryAmount amount)
isGreaterThanOrEqualTo
in interface javax.money.MonetaryAmount
public boolean isEqualTo(javax.money.MonetaryAmount amount)
isEqualTo
in interface javax.money.MonetaryAmount
public boolean isNotEqualTo(javax.money.MonetaryAmount amount)
public RoundedMoney with(javax.money.MonetaryOperator operator)
with
in interface javax.money.MonetaryAmount
public static RoundedMoney from(javax.money.MonetaryAmount amt)
public static RoundedMoney parse(CharSequence text)
text
- the input text, not null.NullPointerException
NumberFormatException
javax.money.UnknownCurrencyException
public 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.MonetaryAmount
public int compareTo(javax.money.MonetaryAmount o)
compareTo
in interface Comparable<javax.money.MonetaryAmount>
public javax.money.NumberValue getNumber()
getNumber
in interface javax.money.NumberSupplier
public BigDecimal asNumberStripped()
isZero()
, and #number
stripTrailingZeros()
in all other cases.public RoundedMoney multiply(long multiplicand)
multiply
in interface javax.money.MonetaryAmount
public RoundedMoney multiply(double multiplicand)
multiply
in interface javax.money.MonetaryAmount
public RoundedMoney divide(long divisor)
divide
in interface javax.money.MonetaryAmount
public RoundedMoney divide(double divisor)
divide
in interface javax.money.MonetaryAmount
public RoundedMoney remainder(long divisor)
remainder
in interface javax.money.MonetaryAmount
public RoundedMoney remainder(double divisor)
remainder
in interface javax.money.MonetaryAmount
public RoundedMoney[] divideAndRemainder(long divisor)
divideAndRemainder
in interface javax.money.MonetaryAmount
public RoundedMoney[] divideAndRemainder(double divisor)
divideAndRemainder
in interface javax.money.MonetaryAmount
public RoundedMoney stripTrailingZeros()
stripTrailingZeros
in interface javax.money.MonetaryAmount
public RoundedMoney divideToIntegralValue(long divisor)
divideToIntegralValue
in interface javax.money.MonetaryAmount
public RoundedMoney divideToIntegralValue(double divisor)
divideToIntegralValue
in interface javax.money.MonetaryAmount
public javax.money.MonetaryAmountFactory<RoundedMoney> getFactory()
getFactory
in interface javax.money.MonetaryAmount
Copyright © 2012-2015 JavaMoney. All Rights Reserved.