public abstract class AbstractCurrencyConversion extends Object implements CurrencyConversion
| Constructor and Description |
|---|
AbstractCurrencyConversion(CurrencyUnit termCurrency,
ConversionContext conversionContext) |
| Modifier and Type | Method and Description |
|---|---|
MonetaryAmount |
apply(MonetaryAmount amount)
Method that converts the source
MonetaryAmount to an
MonetaryAmount based on the ExchangeRate of this
conversion. |
ConversionContext |
getContext()
Access the target
ConversionContext of this conversion instance. |
CurrencyUnit |
getCurrency()
Access the terminating
CurrencyUnit of this conversion instance. |
abstract ExchangeRate |
getExchangeRate(MonetaryAmount amount)
Get the exchange rate type that this
MonetaryOperator instance is
using for conversion. |
protected NumberValue |
roundFactor(MonetaryAmount amount,
NumberValue factor)
Optionally rounds the factor to be used.
|
String |
toString() |
abstract CurrencyConversion |
with(ConversionContext conversionContext) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetExchangeRateProviderpublic static final String KEY_SCALE
public AbstractCurrencyConversion(CurrencyUnit termCurrency, ConversionContext conversionContext)
public CurrencyUnit getCurrency()
CurrencyUnit of this conversion instance.getCurrency in interface CurrencySupplierCurrencyUnit , never null.public ConversionContext getContext()
ConversionContext of this conversion instance.getContext in interface CurrencyConversionConversionContext.public abstract ExchangeRate getExchangeRate(MonetaryAmount amount)
MonetaryOperator instance is
using for conversion.getExchangeRate in interface CurrencyConversionExchangeRate to be used, or null, if this conversion
is not supported (will lead to a
CurrencyConversionException.apply(MonetaryAmount)public abstract CurrencyConversion with(ConversionContext conversionContext)
public MonetaryAmount apply(MonetaryAmount amount)
MonetaryAmount to an
MonetaryAmount based on the ExchangeRate of this
conversion.apply in interface MonetaryOperatoramount - The source amountCurrencyConversionException - if conversion failed, or the required data is not available.getExchangeRate(MonetaryAmount)protected NumberValue roundFactor(MonetaryAmount amount, NumberValue factor)
amount.getContext().getMaxScale() > 0 as follows:
MathContext as context property this is used.RoundingMode, this is used (default is
RoundingMode.HALF_EVEN).amount.getContext().getMaxScale(), this higher scale is used.amount - the amount, not null.factor - the factorCopyright © 2012–2020 JavaMoney. All rights reserved.