Module java.money

Interface MonetaryCurrenciesSingletonSpi


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 CurrencyUnit getCurrency​(java.lang.String currencyCode, java.lang.String... providers)
    Access a new instance based on the currency code.
    default CurrencyUnit getCurrency​(java.util.Locale country, java.lang.String... providers)
    Access a new instance based on the currency code.
    default CurrencyUnit getCurrency​(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 boolean isCurrencyAvailable​(java.lang.String code, java.lang.String... providers)
    Allows to check if a CurrencyUnit instance is defined, i.e.
    default boolean isCurrencyAvailable​(java.util.Locale locale, java.lang.String... providers)
    Allows to check if a CurrencyUnit instance 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.properties is 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 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

      java.util.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​(java.lang.String currencyCode, java.lang.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​(java.util.Locale country, java.lang.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 java.util.Set<CurrencyUnit> getCurrencies​(java.util.Locale locale, java.lang.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​(java.lang.String code, java.lang.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​(java.util.Locale locale, java.lang.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 java.util.Set<CurrencyUnit> getCurrencies​(java.lang.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.