public abstract class AbstractRateProvider
extends java.lang.Object
implements javax.money.convert.ExchangeRateProvider
ExchangeRateProvider
implementations.Modifier and Type | Field and Description |
---|---|
protected java.util.logging.Logger |
LOGGER
The logger used.
|
Constructor and Description |
---|
AbstractRateProvider(javax.money.convert.ProviderContext providerContext)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected static javax.money.NumberValue |
divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor)
A protected helper method to divide 2
NumberValue types. |
protected static javax.money.NumberValue |
divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor,
java.math.MathContext context)
A protected helper method to divide 2
NumberValue types. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(javax.money.CurrencyUnit termCurrency)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(java.lang.String termCode)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.ExchangeRate |
getExchangeRate(javax.money.CurrencyUnit source,
javax.money.CurrencyUnit target)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
protected abstract javax.money.convert.ExchangeRate |
getExchangeRateInternal(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext context) |
javax.money.convert.ProviderContext |
getProviderContext()
Access the
ConversionContext for this
ExchangeRateProvider . |
javax.money.convert.ExchangeRate |
getReversed(javax.money.convert.ExchangeRate rate)
The method reverses the
ExchangeRate to a rate mapping from term
to base CurrencyUnit . |
boolean |
isAvailable(javax.money.CurrencyUnit src,
javax.money.CurrencyUnit target)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(java.lang.String baseCode,
java.lang.String termCode)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
protected static javax.money.NumberValue |
multiply(javax.money.NumberValue multiplicand,
javax.money.NumberValue multiplier)
A protected helper method to multiply 2
NumberValue types. |
public AbstractRateProvider(javax.money.convert.ProviderContext providerContext)
providerContext
- the ProviderContext
, not null.protected static final javax.money.NumberValue divide(javax.money.NumberValue dividend, javax.money.NumberValue divisor)
NumberValue
types.null
an ArithmeticException
is thrown.dividend
- the first value to be divideddivisor
- the value to be divided byNumberValue
protected static final javax.money.NumberValue divide(javax.money.NumberValue dividend, javax.money.NumberValue divisor, java.math.MathContext context)
NumberValue
types.null
an ArithmeticException
is thrown.dividend
- the first value to be divideddivisor
- the value to be divided bycontext
- the MathContext
to useNumberValue
public javax.money.convert.CurrencyConversion getCurrencyConversion(javax.money.CurrencyUnit termCurrency)
javax.money.convert.ExchangeRateProvider
CurrencyConversion
that can be applied as a
MonetaryOperator
to an amount.getCurrencyConversion
in interface javax.money.convert.ExchangeRateProvider
termCurrency
- term CurrencyUnit
, not null
CurrencyConversion
,
never null
.public javax.money.convert.CurrencyConversion getCurrencyConversion(javax.money.CurrencyUnit term, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
CurrencyConversion
that can be applied as a
MonetaryOperator
to an amount.getCurrencyConversion
in interface javax.money.convert.ExchangeRateProvider
term
- term CurrencyUnit
, not null
conversionContext
- the required ConversionContext
, not null
CurrencyConversion
,
never null
.public javax.money.convert.CurrencyConversion getCurrencyConversion(java.lang.String termCode)
javax.money.convert.ExchangeRateProvider
CurrencyConversion
that can be applied as a
MonetaryOperator
to an amount.getCurrencyConversion
in interface javax.money.convert.ExchangeRateProvider
termCode
- terminal/target currency code, not null
CurrencyConversion
,
never null
.public javax.money.convert.CurrencyConversion getCurrencyConversion(java.lang.String termCode, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
CurrencyConversion
that can be applied as a
MonetaryOperator
to an amount.getCurrencyConversion
in interface javax.money.convert.ExchangeRateProvider
termCode
- terminal/target currency code, not null
conversionContext
- the required ConversionContext
, not null
CurrencyConversion
,
never null
.public javax.money.convert.ExchangeRate getExchangeRate(javax.money.CurrencyUnit source, javax.money.CurrencyUnit target)
javax.money.convert.ExchangeRateProvider
ExchangeRate
using the given currencies. The
ExchangeRate
may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis())
.getExchangeRate
in interface javax.money.convert.ExchangeRateProvider
source
- base CurrencyUnit
, not null
target
- term CurrencyUnit
, not null
ExchangeRate
.public javax.money.convert.ExchangeRate getExchangeRate(javax.money.CurrencyUnit base, javax.money.CurrencyUnit term, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
ExchangeRate
using the given currencies. The
ExchangeRate
may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis())
.getExchangeRate
in interface javax.money.convert.ExchangeRateProvider
base
- base CurrencyUnit
, not null
term
- term CurrencyUnit
, not null
conversionContext
- the required ConversionContext
, not null
ExchangeRate
.public javax.money.convert.ExchangeRate getExchangeRate(java.lang.String baseCode, java.lang.String termCode)
javax.money.convert.ExchangeRateProvider
ExchangeRate
using the given currencies. The
ExchangeRate
may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis())
.getExchangeRate
in interface javax.money.convert.ExchangeRateProvider
baseCode
- base currency code, not null
termCode
- term/target currency code, not null
ExchangeRate
.public javax.money.convert.ExchangeRate getExchangeRate(java.lang.String baseCode, java.lang.String termCode, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
ExchangeRate
using the given currencies. The
ExchangeRate
may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis())
.getExchangeRate
in interface javax.money.convert.ExchangeRateProvider
baseCode
- base currency code, not null
termCode
- term/target currency code, not null
conversionContext
- the required ConversionContext
, not null
ExchangeRate
.protected abstract javax.money.convert.ExchangeRate getExchangeRateInternal(javax.money.CurrencyUnit base, javax.money.CurrencyUnit term, javax.money.convert.ConversionContext context)
public javax.money.convert.ProviderContext getProviderContext()
javax.money.convert.ExchangeRateProvider
ConversionContext
for this
ExchangeRateProvider
. Each instance of
ExchangeRateProvider
provides conversion data for exact one
ConversionContext
.getProviderContext
in interface javax.money.convert.ExchangeRateProvider
null
.public javax.money.convert.ExchangeRate getReversed(javax.money.convert.ExchangeRate rate)
javax.money.convert.ExchangeRateProvider
ExchangeRate
to a rate mapping from term
to base CurrencyUnit
. Hereby the factor must not be
recalculated as 1/oldFactor
, since typically reverse rates are
not symmetric in most cases.getReversed
in interface javax.money.convert.ExchangeRateProvider
ExchangeRate
, or null
, if
the rate cannot be reversed.public boolean isAvailable(javax.money.CurrencyUnit src, javax.money.CurrencyUnit target)
javax.money.convert.ExchangeRateProvider
ExchangeRate
between two CurrencyUnit
is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis())
.isAvailable
in interface javax.money.convert.ExchangeRateProvider
src
- the base CurrencyUnit
target
- the term CurrencyUnit
true
, if such an ExchangeRate
is currently
defined.public boolean isAvailable(javax.money.CurrencyUnit base, javax.money.CurrencyUnit term, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
ExchangeRate
between two CurrencyUnit
is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis())
.isAvailable
in interface javax.money.convert.ExchangeRateProvider
base
- the base CurrencyUnit
term
- the term CurrencyUnit
conversionContext
- the required ConversionContext
, not null
true
, if such an ExchangeRate
is currently
defined.public boolean isAvailable(java.lang.String baseCode, java.lang.String termCode)
javax.money.convert.ExchangeRateProvider
ExchangeRate
between two CurrencyUnit
is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis())
.isAvailable
in interface javax.money.convert.ExchangeRateProvider
baseCode
- the base currency codetermCode
- the terminal/target currency codetrue
, if such an ExchangeRate
is currently
defined.public boolean isAvailable(java.lang.String baseCode, java.lang.String termCode, javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProvider
ExchangeRate
between two CurrencyUnit
is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis())
.isAvailable
in interface javax.money.convert.ExchangeRateProvider
baseCode
- the base currency codetermCode
- the terminal/target currency codeconversionContext
- the required ConversionContext
, not null
true
, if such an ExchangeRate
is currently
defined.protected static final javax.money.NumberValue multiply(javax.money.NumberValue multiplicand, javax.money.NumberValue multiplier)
NumberValue
types.null
an ArithmeticException
is thrown.multiplicand
- the first value to be multipliedmultiplier
- the second value to be multipliedNumberValue