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 |
---|---|
CurrencyConversion |
getConversion(ConversionQuery conversionQuery)
Access an instance of
CurrencyConversion . |
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 . |
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. |
Collection<String> |
getProviderNames()
Get all currently registered provider names.
|
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 . |
Collection<String> getProviderNames()
AbstractContext.getProviderName()
List<String> getDefaultProviderChain()
null
and not empty.ExchangeRateProvider getExchangeRateProvider(ConversionQuery conversionQuery)
ExchangeRateProvider
. By setting .ConversionQuery#getRoundingProviderNames()
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 tpye of conversion
required, not null.ExchangeRateProvider
built up with the given sub
providers, never null
MonetaryException
- if a provider could not be found.isExchangeRateProviderAvailable(javax.money.convert.ConversionQuery)
boolean isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
ExchangeRateProvider
is accessible for the given
ConversionQuery
.conversionQuery
- the ConversionQuery
determining the tpye of conversion
required, not null.true
, if such a conversion is supported, meaning an according
ExchangeRateProvider
can be
accessed.getExchangeRateProvider(ConversionQuery)
,
getExchangeRateProvider(String...)}
boolean isConversionAvailable(ConversionQuery conversionQuery)
CurrencyConversion
is accessible for the given
ConversionQuery
.conversionQuery
- the ConversionQuery
determining the tpye 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...)}
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
prpovider 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(CurrencyUnit, String...)}
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.ExchangeRateProvider getExchangeRateProvider(String... providers)
ExchangeRateProvider
based on the given provider chain.providers
- the ConversionQuery
provider names defines a corresponding
prpovider 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.getProviderNames()
,
isExchangeRateProviderAvailable(javax.money.convert.ConversionQuery)
CurrencyConversion getConversion(ConversionQuery conversionQuery)
CurrencyConversion
.conversionQuery
- the ConversionQuery
determining the tpye of conversion
required, not null.MonetaryException
- if no matching conversion could be found.isConversionAvailable(javax.money.convert.ConversionQuery)
CurrencyConversion getConversion(CurrencyUnit termCurrency, String... providers)
CurrencyConversion
.termCurrency
- the terminating/target currency unit, not null.providers
- the ConversionQuery
provider names defines a corresponding
prpovider 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–2015 JSR 354 - Expert Group. All rights reserved.