public interface MonetaryConversionsSingletonSpi
MonetaryConversions singleton accessor. It should be registered as a
service using the JDK ServiceLoader. Hereby only one instance can be
registered at a time.
This interface is designed to support also contextual behaviour, e.g. in Java
EE containers each application may provide its own
ExchangeRateProvider instances, e.g. by registering them as CDI
beans. An EE container can register an according
MonetaryConversionsSingletonSpi that manages the different application
contexts transparently. In a SE environment this class is expected to behave
like an ordinary singleton, loading its SPIs from the ServiceLoader.
Instances of this class must be thread safe. It is not a requirement that they are serializable.
Only one instance can be registered using the ServiceLoader. When
registering multiple instances the MonetaryConversions accessor will
not work.
| Modifier and Type | Method and Description |
|---|---|
default CurrencyConversion |
getConversion(ConversionQuery conversionQuery)
Access an instance of
CurrencyConversion. |
default CurrencyConversion |
getConversion(CurrencyUnit termCurrency,
String... providers)
Access an instance of
CurrencyConversion. |
List<String> |
getDefaultProviderChain()
Get the default provider chain used.
|
ExchangeRateProvider |
getExchangeRateProvider(ConversionQuery conversionQuery)
Access an instance of
ExchangeRateProvider. |
default ExchangeRateProvider |
getExchangeRateProvider(String... providers)
Access a compound instance of an
ExchangeRateProvider based on the given provider chain. |
default List<ExchangeRateProvider> |
getExchangeRateProviders(String... providers)
Access the current registered
ExchangeRateProvider instances. |
Collection<String> |
getProviderNames()
Get all currently registered provider names.
|
default boolean |
isConversionAvailable(ConversionQuery conversionQuery)
Allows to quickly check, if a
CurrencyConversion is accessible for the given
ConversionQuery. |
default boolean |
isConversionAvailable(CurrencyUnit termCurrency,
String... providers)
Allows to quickly check, if a
CurrencyConversion is accessible for the given
ConversionQuery. |
default boolean |
isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
Allows to quickly check, if a
ExchangeRateProvider is accessible for the given
ConversionQuery. |
Collection<String> getProviderNames()
AbstractContext.getProviderName()List<String> getDefaultProviderChain()
null and not empty.ExchangeRateProvider getExchangeRateProvider(ConversionQuery conversionQuery)
ExchangeRateProvider. By setting .ConversionQuery#getCurrencyProviderNames() multiple providers can be selected,
that will be included into a compound instance, with the same order as returned by the .money.convert.ConversionQuery.conversionQuery - the ConversionQuery determining the type of conversion
required, not null.ExchangeRateProvider built up with the given sub
providers, never nullMonetaryException - if a provider could not be found.isExchangeRateProviderAvailable(javax.money.convert.ConversionQuery)default boolean isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
ExchangeRateProvider is accessible for the given
ConversionQuery.conversionQuery - the ConversionQuery determining the type of conversion
required, not null.true, if such a conversion is supported, meaning an according
ExchangeRateProvider can be
accessed.getExchangeRateProvider(ConversionQuery),
getExchangeRateProvider(String...)}default boolean isConversionAvailable(ConversionQuery conversionQuery)
CurrencyConversion is accessible for the given
ConversionQuery.conversionQuery - the ConversionQuery determining the type of conversion
required, not null.true, if such a conversion is supported, meaning an according
CurrencyConversion can be
accessed.getConversion(javax.money.convert.ConversionQuery),
getConversion(CurrencyUnit, String...)}default boolean isConversionAvailable(CurrencyUnit termCurrency, String... providers)
CurrencyConversion is accessible for the given
ConversionQuery.termCurrency - the terminating/target currency unit, not null.providers - the provider names defines a corresponding
provider chain that must be encapsulated by the resulting .money.convert.CurrencyConversion. By default the provider
chain as defined by #getDefaultCurrencyProviderChain will be used.true, if such a conversion is supported, meaning an according
CurrencyConversion can be
accessed.getConversion(javax.money.convert.ConversionQuery),
getConversion(CurrencyUnit, String...)}default List<ExchangeRateProvider> getExchangeRateProviders(String... providers)
ExchangeRateProvider instances. If no provider
names are passed ALL current registered providers are returned in undefined order.providers - the provider names of hte providers to be accessedMonetaryException - if a provider could not be resolved.default ExchangeRateProvider getExchangeRateProvider(String... providers)
ExchangeRateProvider based on the given provider chain.providers - the ConversionQuery provider names defines a corresponding
provider chain that must be
encapsulated by the resulting ExchangeRateProvider. By default
the default
provider changes as defined in #getDefaultCurrencyProviderChain will be used.ExchangeRateProvider built up with the given sub
providers, never null.MonetaryException - if a provider listed could not be found.getProviderNames(),
isExchangeRateProviderAvailable(javax.money.convert.ConversionQuery)default CurrencyConversion getConversion(ConversionQuery conversionQuery)
CurrencyConversion.conversionQuery - the ConversionQuery determining the type of conversion
required, not null.MonetaryException - if no matching conversion could be found.isConversionAvailable(javax.money.convert.ConversionQuery)default CurrencyConversion getConversion(CurrencyUnit termCurrency, String... providers)
CurrencyConversion.termCurrency - the terminating/target currency unit, not null.providers - the ConversionQuery provider names defines a corresponding
provider chain that must be encapsulated by the resulting .money.convert.CurrencyConversion. By default the default
provider chain as defined by #getDefaultCurrencyProviderChain will be used.MonetaryException - if no matching conversion could be found.isConversionAvailable(javax.money.convert.ConversionQuery)Copyright © 2012–2016 JSR 354 - Expert Group. All rights reserved.