public interface 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 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
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.
| Modifier and Type | Method and Description |
|---|---|
ProviderContext |
getContext()
Access the
ConversionContext for this
ExchangeRateProvider. |
CurrencyConversion |
getCurrencyConversion(ConversionQuery conversionQuery)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
default CurrencyConversion |
getCurrencyConversion(CurrencyUnit term)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
default CurrencyConversion |
getCurrencyConversion(String termCode)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
ExchangeRate |
getExchangeRate(ConversionQuery conversionQuery)
Access a
ExchangeRate using the given currencies. |
default ExchangeRate |
getExchangeRate(CurrencyUnit base,
CurrencyUnit term)
Access a
ExchangeRate using the given currencies. |
default ExchangeRate |
getExchangeRate(String baseCode,
String termCode)
Access a
ExchangeRate using the given currencies. |
default ExchangeRate |
getReversed(ExchangeRate rate)
The method reverses the
ExchangeRate to a rate mapping from term
to base CurrencyUnit. |
default boolean |
isAvailable(ConversionQuery conversionQuery)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
default boolean |
isAvailable(CurrencyUnit base,
CurrencyUnit term)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
default boolean |
isAvailable(String baseCode,
String termCode)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
ProviderContext getContext()
ConversionContext for this
ExchangeRateProvider. Each instance of
ExchangeRateProvider provides conversion data for exact one
ConversionContext .null.ExchangeRate getExchangeRate(ConversionQuery conversionQuery)
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.conversionQuery - the required ConversionQuery, not nullExchangeRate.CurrencyConversionException - If no such rate is available.MonetaryException - if one of the currency codes passed is not valid.ConversionQueryBuilderCurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.conversionQuery - the required ConversionQuery, not nullCurrencyConversion,
never null.MonetaryException - if one of the currency codes passed is not valid.ConversionQueryBuilderdefault boolean isAvailable(ConversionQuery conversionQuery)
ExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined.conversionQuery - the required ConversionQuery, not nulltrue, if such an ExchangeRate is currently
defined.default 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.base - base CurrencyUnit, not nullterm - term CurrencyUnit, not nullCurrencyConversionException - If no such rate is available.default CurrencyConversion getCurrencyConversion(CurrencyUnit term)
CurrencyConversion that can be applied as a
MonetaryOperator to an amount.term - term CurrencyUnit, not nullCurrencyConversion,
never null.default 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.base - the base CurrencyUnitterm - the term CurrencyUnittrue, if such an ExchangeRate is currently
defined.default 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.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.default 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.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.default 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.default CurrencyConversion getCurrencyConversion(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.Copyright © 2012–2016 JSR 354 - Expert Group. All rights reserved.