public interface ExchangeRateProvider
ProviderContext.
Instances of this class must only provide conversion data for exact one provider, identified by
ProviderContext.getProviderName().
CurrencyConversion instances from the
MonetaryConversions
in many cases a chain of providers will be returned. It is the reponsibility 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
MonetaryConversionsSpi 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.| 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(CurrencyUnit term,
ConversionContext conversionContext)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
CurrencyConversion |
getCurrencyConversion(java.lang.String termCode)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
CurrencyConversion |
getCurrencyConversion(java.lang.String termCode,
ConversionContext conversionContext)
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(CurrencyUnit base,
CurrencyUnit term,
ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode)
Access a
ExchangeRate using the given currencies. |
ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode,
ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
ProviderContext |
getProviderContext()
Access the
ConversionContext for this
ExchangeRateProvider. |
ExchangeRate |
getReversed(ExchangeRate rate)
The method reverses the
ExchangeRate to a rate mapping from term
to base CurrencyUnit. |
boolean |
isAvailable(CurrencyUnit base,
CurrencyUnit term)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(CurrencyUnit base,
CurrencyUnit term,
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,
ConversionContext conversionContext)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
CurrencyConversion getCurrencyConversion(CurrencyUnit term)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.term - term CurrencyUnit, not nullCurrencyConversion,
never null.CurrencyConversion getCurrencyConversion(CurrencyUnit term, ConversionContext conversionContext)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.term - term CurrencyUnit, not nullconversionContext - the required ConversionContext, not nullCurrencyConversion,
never null.CurrencyConversion getCurrencyConversion(java.lang.String termCode)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.termCode - terminal/target currency code, not nullCurrencyConversion,
never null.MonetaryException - if one of the currency codes passed is not valid.CurrencyConversion getCurrencyConversion(java.lang.String termCode, ConversionContext conversionContext)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.termCode - terminal/target currency code, not nullconversionContext - the required ConversionContext, not nullCurrencyConversion,
never null.MonetaryException - if one of the currency codes passed is not valid.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. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).base - base CurrencyUnit, not nullterm - term CurrencyUnit, not nullExchangeRate.CurrencyConversionException - If no such rate is available.ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term, ConversionContext conversionContext)
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()).base - base CurrencyUnit, not nullterm - term CurrencyUnit, not nullconversionContext - the required ConversionContext, not nullExchangeRate.CurrencyConversionException - If no such rate is available.ExchangeRate getExchangeRate(java.lang.String baseCode, java.lang.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. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).baseCode - 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.ExchangeRate getExchangeRate(java.lang.String baseCode, java.lang.String termCode, ConversionContext conversionContext)
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()).baseCode - base currency code, not nulltermCode - term/target currency code, not nullconversionContext - the required ConversionContext, not nullExchangeRate.CurrencyConversionException - If no such rate is available.MonetaryException - if one of the currency codes passed is not valid.ProviderContext getProviderContext()
ConversionContext for this
ExchangeRateProvider. Each instance of
ExchangeRateProvider provides conversion data for exact one
ConversionContext .null.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.ExchangeRate, or null, if
the rate cannot be reversed.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. It should be the same as
isAvailable(base, term, System.currentTimeMillis()).base - the base CurrencyUnitterm - the term CurrencyUnittrue, if such an ExchangeRate is currently
defined.boolean isAvailable(CurrencyUnit base, CurrencyUnit term, ConversionContext conversionContext)
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()).base - the base CurrencyUnitterm - the term CurrencyUnitconversionContext - the required ConversionContext, not nulltrue, if such an ExchangeRate is currently
defined.boolean isAvailable(java.lang.String baseCode,
java.lang.String termCode)
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()).baseCode - 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.boolean isAvailable(java.lang.String baseCode,
java.lang.String termCode,
ConversionContext conversionContext)
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()).baseCode - the base currency codetermCode - the terminal/target currency codeconversionContext - the required ConversionContext, not nulltrue, if such an ExchangeRate is currently
defined.MonetaryException - if one of the currency codes passed is not valid.