Module java.money

Interface MonetaryCurrenciesSingletonSpi

All Known Implementing Classes:
DefaultMonetaryCurrenciesSingletonSpi

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
  • Method Details

    • getDefaultProviderChain

      List<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.properties is used.
      See Also:
    • getProviderNames

      Set<String> getProviderNames()
      Access a list of the currently registered providers. The names can be used to access subsets of the overall currency range by calling getCurrencies(String...).
      Returns:
      the currencies returned by the given provider chain. If not provider names are provided the default provider chain configured in javamoney.properties is used.
    • getCurrencies

      Set<CurrencyUnit> getCurrencies(CurrencyQuery query)
      Access all currencies matching the given query.
      Parameters:
      query - The currency query, not null.
      Returns:
      a set of all currencies found, never null.
    • getCurrency

      default CurrencyUnit getCurrency(String currencyCode, String... providers)
      Access a new instance based on the currency code. Currencies are available as provided by CurrencyProviderSpi instances registered with the Bootstrap.
      Parameters:
      currencyCode - the ISO currency code, not null.
      providers - the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.
      Returns:
      the corresponding CurrencyUnit instance.
      Throws:
      UnknownCurrencyException - if no such currency exists.
    • getCurrency

      default CurrencyUnit getCurrency(Locale country, String... providers)
      Access a new instance based on the currency code. Currencies are available as provided by CurrencyProviderSpi instances registered with the Bootstrap.
      Parameters:
      country - the ISO currency's country, not null.
      providers - the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.
      Returns:
      the corresponding CurrencyUnit instance.
      Throws:
      UnknownCurrencyException - if no such currency exists.
    • getCurrencies

      default Set<CurrencyUnit> getCurrencies(Locale locale, String... providers)
      Provide access to all currently known currencies.
      Parameters:
      locale - the target Locale, typically representing an ISO country, not null.
      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(String code, String... providers)
      Allows to check if a CurrencyUnit instance is defined, i.e. accessible from getCurrency(String, String...).
      Parameters:
      code - the currency code, not null.
      providers - the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.
      Returns:
      true if getCurrency(String, String...) would return a result for the given code.
    • isCurrencyAvailable

      default boolean isCurrencyAvailable(Locale locale, String... providers)
      Allows to check if a CurrencyUnit instance is defined, i.e. accessible from getCurrency(String, String...).
      Parameters:
      locale - the target Locale, not null.
      providers - the (optional) specification of providers to consider. If not set (empty) the providers as defined by #getDefaultCurrencyProviderChain() should be used.
      Returns:
      true if getCurrencies(java.util.Locale, String...) would return a non empty result for the given code.
    • getCurrencies

      default Set<CurrencyUnit> getCurrencies(String... providers)
      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

      default CurrencyUnit getCurrency(CurrencyQuery query)
      Access a single currency by query.
      Parameters:
      query - The currency query, not null.
      Returns:
      the CurrencyUnit found, never null.
      Throws:
      MonetaryException - if multiple currencies match the query.