public abstract class BaseExchangeRateProvider extends Object implements ExchangeRateProvider
ProviderContext.
Instances of this class must only provide conversion data for exact one provider, identified by
AbstractContext.getProviderName().
When accessing ExchangeRateProvider instances or CurrencyConversion instances from the
MonetaryConversions
in many cases a chain of providers will be returned. It is the responsibility of the implementation code assembling
the chain to
establish a well defined coordination mechanism for evaluating the correct result. By default the first provider
in the chain that returns a non null result determines the final result of a call. Nevertheless adapting the
MonetaryConversionsSingletonSpi allows
to implement also alternate strategies, e.g. honoring different priorities of providers as well.
Implementations of this interface are required to be thread save.
Implementations of this class must neither be immutable nor serializable.| Constructor and Description |
|---|
BaseExchangeRateProvider() |
| Modifier and Type | Method and Description |
|---|---|
CurrencyConversion |
getCurrencyConversion(CurrencyUnit term)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
CurrencyConversion |
getCurrencyConversion(String termCode)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
ExchangeRate |
getExchangeRate(CurrencyUnit base,
CurrencyUnit term)
Access a
ExchangeRate using the given currencies. |
ExchangeRate |
getExchangeRate(String baseCode,
String termCode)
Access a
ExchangeRate using the given currencies. |
ExchangeRate |
getReversed(ExchangeRate rate)
The method reverses the
ExchangeRate to a rate mapping from term
to base CurrencyUnit. |
boolean |
isAvailable(ConversionQuery conversionQuery)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(CurrencyUnit base,
CurrencyUnit term)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(String baseCode,
String termCode)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetContext, getCurrencyConversion, getExchangeRatepublic BaseExchangeRateProvider()
public boolean isAvailable(ConversionQuery conversionQuery)
ExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined.isAvailable in interface ExchangeRateProviderconversionQuery - the required ConversionQuery, not nulltrue, if such an ExchangeRate is currently
defined.public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term)
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.getExchangeRate in interface ExchangeRateProviderbase - base CurrencyUnit, not nullterm - term CurrencyUnit, not nullCurrencyConversionException - If no such rate is available.public CurrencyConversion getCurrencyConversion(CurrencyUnit term)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface ExchangeRateProviderterm - term CurrencyUnit, not nullCurrencyConversion,
never null.public boolean isAvailable(CurrencyUnit base, CurrencyUnit term)
ExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined.isAvailable in interface ExchangeRateProviderbase - the base CurrencyUnitterm - the term CurrencyUnittrue, if such an ExchangeRate is currently
defined.public boolean isAvailable(String baseCode, String termCode)
ExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined.isAvailable in interface ExchangeRateProviderbaseCode - the base currency codetermCode - the terminal/target currency codetrue, if such an ExchangeRate is currently
defined.MonetaryException - if one of the currency codes passed is not valid.public ExchangeRate getExchangeRate(String baseCode, String termCode)
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.getExchangeRate in interface ExchangeRateProviderbaseCode - base currency code, not nulltermCode - term/target currency code, not nullExchangeRate.CurrencyConversionException - If no such rate is available.MonetaryException - if one of the currency codes passed is not valid.public ExchangeRate getReversed(ExchangeRate rate)
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 ExchangeRateProviderExchangeRate, or null, if
the rate cannot be reversed.public CurrencyConversion getCurrencyConversion(String termCode)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface ExchangeRateProvidertermCode - terminal/target currency code, not nullCurrencyConversion,
never null.MonetaryException - if one of the currency codes passed is not valid.Copyright © 2012–2020 JavaMoney. All rights reserved.