Top Description Methods
javax.money.convert

public Interface ExchangeRateProvider

Imports
javax.money.*, java.util.Objects

This interface defines access to the exchange rates provided by a provider. The provider and its capabilities can be defined in arbitrary detail by the corresponding javax.money.convert.ProviderContext. Instances of this class must only provide conversion data for exact one provider, identified by ProviderContext#getProviderName(). When accessing ExchangeRateProvider instances or javax.money.convert.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 javax.money.spi.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.

Authors
Anatole Tresch, Werner Keil

Method Summary

Modifier and TypeMethod and Description
public ProviderContext

Returns:

the exchange rate type, never null.
getContext
()

Access the ConversionContext for this ExchangeRateProvider.

public CurrencyConversion

Returns:

a new instance of a corresponding CurrencyConversion, never null.
getCurrencyConversion
(ConversionQuery
the required ConversionQuery, not null
conversionQuery
)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

public default CurrencyConversion

Returns:

a new instance of a corresponding CurrencyConversion, never null.
getCurrencyConversion
(CurrencyUnit
term CurrencyUnit, not null
term
)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

public default CurrencyConversion

Returns:

a new instance of a corresponding CurrencyConversion, never null.
getCurrencyConversion
(String
terminal/target currency code, not null
termCode
)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

public ExchangeRate

Returns:

the matching ExchangeRate.
getExchangeRate
(ConversionQuery
the required ConversionQuery, not null
conversionQuery
)

Access a ExchangeRate using the given currencies.

public default ExchangeRate

Returns:

the matching ExchangeRate.
getExchangeRate
(CurrencyUnit
base CurrencyUnit, not null
base
,
CurrencyUnit
term CurrencyUnit, not null
term
)

Access a ExchangeRate using the given currencies.

public default ExchangeRate

Returns:

the matching ExchangeRate.
getExchangeRate
(String
base currency code, not null
baseCode
,
String
term/target currency code, not null
termCode
)

Access a ExchangeRate using the given currencies.

public default ExchangeRate

Returns:

the matching reversed ExchangeRate, or null, if the rate cannot be reversed.
getReversed
(ExchangeRate
ExchangeRate, not null
rate
)

The method reverses the ExchangeRate to a rate mapping from term to base CurrencyUnit.

public default boolean

Returns:

true, if such an ExchangeRate is currently defined.
isAvailable
(ConversionQuery
the required ConversionQuery, not null
conversionQuery
)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider.

public default boolean

Returns:

true, if such an ExchangeRate is currently defined.
isAvailable
(CurrencyUnit
the base CurrencyUnit
base
,
CurrencyUnit
the term CurrencyUnit
term
)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider.

public default boolean

Returns:

true, if such an ExchangeRate is currently defined.
isAvailable
(String
the base currency code
baseCode
,
String
the terminal/target currency code
termCode
)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider.

Method Detail

getContextback to summary
public ProviderContext getContext()

Access the ConversionContext for this ExchangeRateProvider. Each instance of ExchangeRateProvider provides conversion data for exact one ConversionContext .

Returns:ProviderContext

the exchange rate type, never null.

getCurrencyConversionback to summary
public CurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

Parameters
conversionQuery:ConversionQuery

the required ConversionQuery, not null

Returns:CurrencyConversion

a new instance of a corresponding CurrencyConversion, never null.

Exceptions
MonetaryException:
if one of the currency codes passed is not valid.
See Also
javax.money.convert.ConversionQueryBuilder
getCurrencyConversionback to summary
public default CurrencyConversion getCurrencyConversion(CurrencyUnit term)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

Parameters
term:CurrencyUnit

term CurrencyUnit, not null

Returns:CurrencyConversion

a new instance of a corresponding CurrencyConversion, never null.

getCurrencyConversionback to summary
public default CurrencyConversion getCurrencyConversion(String termCode)

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

Parameters
termCode:String

terminal/target currency code, not null

Returns:CurrencyConversion

a new instance of a corresponding CurrencyConversion, never null.

Exceptions
MonetaryException:
if one of the currency codes passed is not valid.
getExchangeRateback to summary
public ExchangeRate getExchangeRate(ConversionQuery conversionQuery)

Access a ExchangeRate using the given currencies. The ExchangeRate may be, depending on the data provider, real-time or deferred. This method should return the rate that is currently valid.

Parameters
conversionQuery:ConversionQuery

the required ConversionQuery, not null

Returns:ExchangeRate

the matching ExchangeRate.

Exceptions
CurrencyConversionException:
If no such rate is available.
MonetaryException:
if one of the currency codes passed is not valid.
See Also
javax.money.convert.ConversionQueryBuilder
getExchangeRateback to summary
public default ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term)

Access a ExchangeRate using the given currencies. The ExchangeRate may be, depending on the data provider, real-time or deferred. This method should return the rate that is currently valid.

Parameters
base:CurrencyUnit

base CurrencyUnit, not null

term:CurrencyUnit

term CurrencyUnit, not null

Returns:ExchangeRate

the matching ExchangeRate.

Exceptions
CurrencyConversionException:
If no such rate is available.
getExchangeRateback to summary
public default ExchangeRate getExchangeRate(String baseCode, String termCode)

Access a ExchangeRate using the given currencies. The ExchangeRate may be, depending on the data provider, real-time or deferred. This method should return the rate that is currently valid.

Parameters
baseCode:String

base currency code, not null

termCode:String

term/target currency code, not null

Returns:ExchangeRate

the matching ExchangeRate.

Exceptions
CurrencyConversionException:
If no such rate is available.
MonetaryException:
if one of the currency codes passed is not valid.
getReversedback to summary
public default ExchangeRate getReversed(ExchangeRate rate)

The method reverses the 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.

Parameters
rate:ExchangeRate

ExchangeRate, not null

Returns:ExchangeRate

the matching reversed ExchangeRate, or null, if the rate cannot be reversed.

isAvailableback to summary
public default boolean isAvailable(ConversionQuery conversionQuery)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider. This method should check, if a given rate is currently defined.

Parameters
conversionQuery:ConversionQuery

the required ConversionQuery, not null

Returns:boolean

true, if such an ExchangeRate is currently defined.

isAvailableback to summary
public default boolean isAvailable(CurrencyUnit base, CurrencyUnit term)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider. This method should check, if a given rate is currently defined.

Parameters
base:CurrencyUnit

the base CurrencyUnit

term:CurrencyUnit

the term CurrencyUnit

Returns:boolean

true, if such an ExchangeRate is currently defined.

isAvailableback to summary
public default boolean isAvailable(String baseCode, String termCode)

Checks if an ExchangeRate between two CurrencyUnit is available from this provider. This method should check, if a given rate is currently defined.

Parameters
baseCode:String

the base currency code

termCode:String

the terminal/target currency code

Returns:boolean

true, if such an ExchangeRate is currently defined.

Exceptions
MonetaryException:
if one of the currency codes passed is not valid.