public interface MonetaryCurrenciesSingletonSpi
Factory singleton backing interface for
Monetary that provides access to
different registered CurrencyProviderSpi instances.
Implementations of this interface must be thread safe.
- Version:
- 0.8
- Author:
- Anatole Tresch
-
Method Summary
Modifier and Type Method Description default java.util.Set<CurrencyUnit>getCurrencies(java.lang.String... providers)Provide access to all currently known currencies.default java.util.Set<CurrencyUnit>getCurrencies(java.util.Locale locale, java.lang.String... providers)Provide access to all currently known currencies.java.util.Set<CurrencyUnit>getCurrencies(CurrencyQuery query)Access all currencies matching the given query.default CurrencyUnitgetCurrency(java.lang.String currencyCode, java.lang.String... providers)Access a new instance based on the currency code.default CurrencyUnitgetCurrency(java.util.Locale country, java.lang.String... providers)Access a new instance based on the currency code.default CurrencyUnitgetCurrency(CurrencyQuery query)Access a single currency by query.java.util.List<java.lang.String>getDefaultProviderChain()Access a list of the currently registered default providers.java.util.Set<java.lang.String>getProviderNames()Access a list of the currently registered providers.default booleanisCurrencyAvailable(java.lang.String code, java.lang.String... providers)Allows to check if aCurrencyUnitinstance is defined, i.e.default booleanisCurrencyAvailable(java.util.Locale locale, java.lang.String... providers)Allows to check if aCurrencyUnitinstance is defined, i.e.
-
Method Details
-
getDefaultProviderChain
java.util.List<java.lang.String> getDefaultProviderChain()Access a list of the currently registered default providers. The default providers are used, when no provider names are passed by the caller.- Returns:
- the currencies returned by the given provider chain. If not provider names are provided
the default provider chain configured in
javamoney.propertiesis used. - See Also:
getCurrencies(String...),CurrencyQueryBuilder
-
getProviderNames
java.util.Set<java.lang.String> getProviderNames()Access a list of the currently registered providers. The names can be used to access subsets of the overall currency range by callinggetCurrencies(String...).- Returns:
- the currencies returned by the given provider chain. If not provider names are provided
the default provider chain configured in
javamoney.propertiesis used.
-
getCurrencies
Access all currencies matching the given query.- Parameters:
query- The currency query, not null.- Returns:
- a set of all currencies found, never null.
-
getCurrency
Access a new instance based on the currency code. Currencies are available as provided byCurrencyProviderSpiinstances registered with theBootstrap.- Parameters:
currencyCode- the ISO currency code, notnull.providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
- the corresponding
CurrencyUnitinstance. - Throws:
UnknownCurrencyException- if no such currency exists.
-
getCurrency
Access a new instance based on the currency code. Currencies are available as provided byCurrencyProviderSpiinstances registered with theBootstrap.- Parameters:
country- the ISO currency's country, notnull.providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
- the corresponding
CurrencyUnitinstance. - Throws:
UnknownCurrencyException- if no such currency exists.
-
getCurrencies
default java.util.Set<CurrencyUnit> getCurrencies(java.util.Locale locale, java.lang.String... providers)Provide access to all currently known currencies.- Parameters:
locale- the targetLocale, typically representing an ISO country, notnull.providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
- a collection of all known currencies, never null.
-
isCurrencyAvailable
default boolean isCurrencyAvailable(java.lang.String code, java.lang.String... providers)Allows to check if aCurrencyUnitinstance is defined, i.e. accessible fromgetCurrency(String, String...).- Parameters:
code- the currency code, notnull.providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
trueifgetCurrency(String, String...)would return a result for the given code.
-
isCurrencyAvailable
default boolean isCurrencyAvailable(java.util.Locale locale, java.lang.String... providers)Allows to check if aCurrencyUnitinstance is defined, i.e. accessible fromgetCurrency(String, String...).- Parameters:
locale- the targetLocale, notnull.providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
trueifgetCurrencies(java.util.Locale, String...)would return a non empty result for the given code.
-
getCurrencies
Provide access to all currently known currencies.- Parameters:
providers- the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.- Returns:
- a collection of all known currencies, never null.
-
getCurrency
Access a single currency by query.- Parameters:
query- The currency query, not null.- Returns:
- the
CurrencyUnitfound, never null. - Throws:
MonetaryException- if multiple currencies match the query.
-