public interface CurrencyConversion extends MonetaryOperator, CurrencySupplier
CurrencyConversionthat is converting a
MonetaryAmountwith a different target
CurrencyUnit. Each instance of this class is bound to a specific
ExchangeRateProvider(or a chain of rate providers), a term
CurrencyUnitand (optionally) a target timestamp. Additionally the
ConversionContextcan have additional attributes set that are passed to the rate provider (chain).
This interface serves a an API for the clients, but also must be implemented
and registered as SPI to the mechanisms required by the
MonetaryAmount amount = ...; CurrencyConversion conversion = MonetaryConversions.getConversion("CHF"); MonetaryAmount amountInCHF = amount.with(conversion);
CurrencyUnit of this conversion instance can be
getCurrency(), inherited from
Instances of this class are required to be thread-safe, but it is not a requirement that they are serializable. In a EE context they can be implemented using contextual beans.
- Anatole Tresch, Werner Keil
ConversionContext getContext()Access the target
ConversionContextof this conversion instance.
- the target
ExchangeRateProvider getExchangeRateProvider()Access the underlying
- the underlying
ExchangeRateProvider, never null.