public final class MonetaryConversions extends Object
ExchangeRateProvider and CurrencyConversion instances.
This class is thread safe.
This class 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 e.g. from the
JDK ServiceLoader or an alternate component and service provider.
This class is thread-safe. Hereby it is important to know that it delegates
to the registered MonetaryConversionsSingletonSpi SPI, which also is required
to be thread-safe.
| Modifier and Type | Method and Description |
|---|---|
static CurrencyConversion |
getConversion(ConversionQuery conversionQuery)
Access an instance of
CurrencyConversion for the given providers. |
static CurrencyConversion |
getConversion(CurrencyUnit termCurrency,
String... providers)
Access an instance of
CurrencyConversion for the given providers. |
static CurrencyConversion |
getConversion(String termCurrencyCode,
String... providers)
Access an instance of
CurrencyConversion for the given providers. |
static Collection<String> |
getConversionProviderNames()
Return the (non localized) names of all providers available in the
current context.
|
static List<String> |
getDefaultConversionProviderChain()
Get the default provider used.
|
static ExchangeRateProvider |
getExchangeRateProvider(ConversionQuery conversionQuery)
Access an instance of
CurrencyConversion using the given
providers as a provider chain. |
static ExchangeRateProvider |
getExchangeRateProvider(ExchangeRateProviderSupplier provider,
ExchangeRateProviderSupplier... providers)
Access an instance of
CurrencyConversion using the
ExchangeRateProviderSupplier. |
static ExchangeRateProvider |
getExchangeRateProvider(String... providers)
Access an instance of
CurrencyConversion using the given
providers as a provider chain. |
static boolean |
isConversionAvailable(ConversionQuery conversionQuery)
Checks if a
CurrencyConversion is available for the given parameters. |
static boolean |
isConversionAvailable(CurrencyUnit termCurrency,
String... providers)
Checks if a
CurrencyConversion is available for the given parameters. |
static boolean |
isConversionAvailable(String currencyCode,
String... providers)
Checks if a
CurrencyConversion is available for the given parameters. |
static boolean |
isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
Checks if a
ExchangeRateProvider is available for the given parameters. |
public static CurrencyConversion getConversion(CurrencyUnit termCurrency, String... providers)
CurrencyConversion for the given providers.
Use getConversionProviderNames() to check, which are available.termCurrency - the terminating or target currency, not nullproviders - Additional providers, for building a provider chainIllegalArgumentException - if no such ExchangeRateProvider is available.public static CurrencyConversion getConversion(String termCurrencyCode, String... providers)
CurrencyConversion for the given providers.
Use getConversionProviderNames()} to check, which are available.termCurrencyCode - the terminating or target currency code, not nullproviders - Additional providers, for building a provider chainMonetaryException - if no such ExchangeRateProvider is available or if no CurrencyUnit was
matching the given currency code.public static CurrencyConversion getConversion(ConversionQuery conversionQuery)
CurrencyConversion for the given providers.
Use getConversionProviderNames()} to check, which are available.conversionQuery - The ConversionQuery required, not nullCurrencyConversion instance matching.IllegalArgumentException - if the query defines ExchangeRateProviders that are not available.public static boolean isConversionAvailable(ConversionQuery conversionQuery)
CurrencyConversion is available for the given parameters.conversionQuery - the ConversionQuery, not null.getConversion(ConversionQuery).public static boolean isConversionAvailable(String currencyCode, String... providers)
CurrencyConversion is available for the given parameters.currencyCode - The currencoy code, resolvable by (String, String...)providers - Additional providers, for building a provider chaingetConversion(String, String...).public static boolean isConversionAvailable(CurrencyUnit termCurrency, String... providers)
CurrencyConversion is available for the given parameters.termCurrency - the terminating or target currency, not nullproviders - Additional providers, for building a provider chaingetConversion(String, String...).public static ExchangeRateProvider getExchangeRateProvider(String... providers)
CurrencyConversion using the given
providers as a provider chain. Use getConversionProviderNames()s
to check, which are available.IllegalArgumentException - if no such ExchangeRateProvider is available.public static ExchangeRateProvider getExchangeRateProvider(ExchangeRateProviderSupplier provider, ExchangeRateProviderSupplier... providers)
CurrencyConversion using the
ExchangeRateProviderSupplier.provider - the exchange rate provider.providers - the exchange rate provider.IllegalArgumentException - if no such ExchangeRateProvider is available.public static ExchangeRateProvider getExchangeRateProvider(ConversionQuery conversionQuery)
CurrencyConversion using the given
providers as a provider chain. Use getConversionProviderNames()
to check, which are available.IllegalArgumentException - if no such ExchangeRateProvider is available.public static boolean isExchangeRateProviderAvailable(ConversionQuery conversionQuery)
ExchangeRateProvider is available for the given parameters.conversionQuery - the ConversionQuery, not null.getExchangeRateProvider(ConversionQuery)}.public static Collection<String> getConversionProviderNames()
ExchangeRateProvider or CurrencyConversion instances.null.Copyright © 2012–2016 JSR 354 - Expert Group. All rights reserved.