public abstract class BaseMonetaryConversionsSingletonSpi extends Object implements 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
BaseMonetaryConversionsSingletonSpi 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.| Constructor and Description |
|---|
BaseMonetaryConversionsSingletonSpi() |
| Modifier and Type | Method and Description |
|---|---|
CurrencyConversion |
getConversion(ConversionQuery conversionQuery)
Access an instance of
CurrencyConversion. |
CurrencyConversion |
getConversion(CurrencyUnit termCurrency,
String... providers)
Access an instance of
CurrencyConversion. |
ExchangeRateProvider |
getExchangeRateProvider(String... providers)
Access a compound instance of an
ExchangeRateProvider based on the given provider chain. |
List<ExchangeRateProvider> |
getExchangeRateProviders(String... providers)
Access the current registered
ExchangeRateProvider instances. |
boolean |
isConversionAvailable(ConversionQuery conversionQuery)
Allows to quickly check, if a
CurrencyConversion is accessible for the given
ConversionQuery. |
boolean |
isConversionAvailable(CurrencyUnit termCurrency,
String... providers)
Allows to quickly check, if a
CurrencyConversion is accessible for the given
ConversionQuery. |
boolean |
isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
Allows to quickly check, if a
ExchangeRateProvider is accessible for the given
ConversionQuery. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefaultProviderChain, getExchangeRateProvider, getProviderNamespublic BaseMonetaryConversionsSingletonSpi()
public boolean isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
ExchangeRateProvider is accessible for the given
ConversionQuery.isExchangeRateProviderAvailable in interface MonetaryConversionsSingletonSpiconversionQuery - the ConversionQuery determining the type of conversion
required, not null.true, if such a conversion is supported, meaning an according
ExchangeRateProvider can be
accessed.MonetaryConversionsSingletonSpi.getExchangeRateProvider(javax.money.convert.ConversionQuery),
getExchangeRateProvider(String...)}public boolean isConversionAvailable(ConversionQuery conversionQuery)
CurrencyConversion is accessible for the given
ConversionQuery.isConversionAvailable in interface MonetaryConversionsSingletonSpiconversionQuery - 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(javax.money.CurrencyUnit, String...)}public boolean isConversionAvailable(CurrencyUnit termCurrency, String... providers)
CurrencyConversion is accessible for the given
ConversionQuery.isConversionAvailable in interface MonetaryConversionsSingletonSpitermCurrency - 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 #getDefaultRoundingProviderChain will be used.true, if such a conversion is supported, meaning an according
CurrencyConversion can be
accessed.getConversion(javax.money.convert.ConversionQuery),
getConversion(javax.money.CurrencyUnit, String...)}public List<ExchangeRateProvider> getExchangeRateProviders(String... providers)
ExchangeRateProvider instances. If no provider
names are passed ALL current registered providers are returned in undefined order.getExchangeRateProviders in interface MonetaryConversionsSingletonSpiproviders - the provider names of hte providers to be accessedMonetaryException - if a provider could not be resolved.public ExchangeRateProvider getExchangeRateProvider(String... providers)
ExchangeRateProvider based on the given provider chain.getExchangeRateProvider in interface MonetaryConversionsSingletonSpiproviders - 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 #getDefaultRoundingProviderChain will be used.ExchangeRateProvider built up with the given sub
providers, never null.MonetaryException - if a provider listed could not be found.MonetaryConversionsSingletonSpi.getProviderNames(),
isExchangeRateProviderAvailable(javax.money.convert.ConversionQuery)public CurrencyConversion getConversion(ConversionQuery conversionQuery)
CurrencyConversion.getConversion in interface MonetaryConversionsSingletonSpiconversionQuery - the ConversionQuery determining the type of conversion
required, not null.MonetaryException - if no matching conversion could be found.isConversionAvailable(javax.money.convert.ConversionQuery)public CurrencyConversion getConversion(CurrencyUnit termCurrency, String... providers)
CurrencyConversion.getConversion in interface MonetaryConversionsSingletonSpitermCurrency - 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 #getDefaultRoundingProviderChain will be used.MonetaryException - if no matching conversion could be found.isConversionAvailable(javax.money.convert.ConversionQuery)Copyright © 2012–2020 JavaMoney. All rights reserved.