public final class Monetary extends Object
CurrencyUnit, MonetaryAmount and
MonetaryRounding instances as provided by the
different registered SPI instances.
This class is thread safe.| Modifier and Type | Method and Description |
|---|---|
static Collection<MonetaryAmountFactory<?>> |
getAmountFactories()
Access all currently available
MonetaryAmount implementation classes that are
accessible from this MonetaryAmount singleton. |
static Collection<MonetaryAmountFactory<?>> |
getAmountFactories(MonetaryAmountFactoryQuery query)
Returns all factory instances that match the query.
|
static <T extends MonetaryAmount> |
getAmountFactory(Class<T> amountType)
Access an
MonetaryAmountFactory for the given MonetaryAmount implementation
type. |
static MonetaryAmountFactory |
getAmountFactory(MonetaryAmountFactoryQuery query)
Executes the query and returns the factory found, if there is only one factory.
|
static Collection<Class<? extends MonetaryAmount>> |
getAmountTypes()
Access all currently available
MonetaryAmount implementation classes that are
accessible from this MonetaryAmount singleton. |
static Collection<CurrencyUnit> |
getCurrencies(CurrencyQuery query)
Query all currencies matching the given query.
|
static Set<CurrencyUnit> |
getCurrencies(Locale locale,
String... providers)
Access a new instance based on the
Locale. |
static Collection<CurrencyUnit> |
getCurrencies(String... providers)
Access all currencies known.
|
static CurrencyUnit |
getCurrency(CurrencyQuery query)
Query all currencies matching the given query.
|
static CurrencyUnit |
getCurrency(Locale locale,
String... providers)
Access a new instance based on the
Locale. |
static CurrencyUnit |
getCurrency(String currencyCode,
String... providers)
Access a new instance based on the currency code.
|
static Set<String> |
getCurrencyProviderNames()
Query all currencies matching the given query.
|
static MonetaryAmountFactory<?> |
getDefaultAmountFactory()
Access the default
MonetaryAmountFactory as defined by
MonetaryAmountsSingletonSpi.getDefaultAmountFactory(). |
static Class<? extends MonetaryAmount> |
getDefaultAmountType()
Access the default
MonetaryAmount implementation class that is
accessible from this MonetaryAmount singleton. |
static List<String> |
getDefaultCurrencyProviderChain()
Query the list and ordering of provider names modelling the default provider chain to be used, if no provider
chain was explicitly set..
|
static MonetaryRounding |
getDefaultRounding()
Creates a rounding that can be added as
MonetaryOperator to
chained calculations. |
static List<String> |
getDefaultRoundingProviderChain()
Allows to access the default providers chain used if no provider chain was passed explicitly..
|
static MonetaryRounding |
getRounding(CurrencyUnit currencyUnit,
String... providers)
Creates an
MonetaryOperator for rounding MonetaryAmount
instances given a currency. |
static MonetaryRounding |
getRounding(RoundingQuery roundingQuery)
Access a
MonetaryRounding using a possibly complex query. |
static MonetaryRounding |
getRounding(String roundingName,
String... providers)
Access an
MonetaryOperator for custom rounding
MonetaryAmount instances. |
static Set<String> |
getRoundingNames(String... providers)
Allows to access the names of the current defined roundings.
|
static Set<String> |
getRoundingProviderNames()
Allows to access the names of the current registered providers.
|
static Collection<MonetaryRounding> |
getRoundings(RoundingQuery roundingQuery)
Access multiple
MonetaryRounding instances using a possibly complex query |
static boolean |
isAvailable(MonetaryAmountFactoryQuery query)
Allows to check if any of the getXXX methods return non empty/non null results of
.MonetaryAmountFactory. |
static boolean |
isCurrencyAvailable(Locale locale,
String... providers)
Allows to check if a
CurrencyUnit instance is
defined, i.e. |
static boolean |
isCurrencyAvailable(String code,
String... providers)
Allows to check if a
CurrencyUnit instance is defined, i.e. |
static boolean |
isRoundingAvailable(CurrencyUnit currencyUnit,
String... providers)
Checks if a
MonetaryRounding is available given a roundingId. |
static boolean |
isRoundingAvailable(RoundingQuery roundingQuery)
Checks if a
MonetaryRounding matching the query is available. |
static boolean |
isRoundingAvailable(String roundingName,
String... providers)
Checks if a
MonetaryRounding is available given a roundingId. |
public static Set<String> getRoundingProviderNames()
null.public static List<String> getDefaultRoundingProviderChain()
null.public static MonetaryRounding getDefaultRounding()
MonetaryOperator to
chained calculations. The instance will lookup the concrete
MonetaryOperator instance from the Monetary
based on the input MonetaryAmount's CurrencyUnit.public static MonetaryRounding getRounding(CurrencyUnit currencyUnit, String... providers)
MonetaryOperator for rounding MonetaryAmount
instances given a currency.currencyUnit - The currency, which determines the required scale. As
RoundingMode, by default, RoundingMode.HALF_UP
is used.providers - the providers and ordering to be used. By default providers and ordering as defined in
#getDefaultProviders is used.MonetaryOperator implementing the
rounding, never null.public static MonetaryRounding getRounding(String roundingName, String... providers)
MonetaryOperator for custom rounding
MonetaryAmount instances.roundingName - The rounding identifier.providers - the providers and ordering to be used. By default providers and ordering as defined in
#getDefaultProviders is used.MonetaryOperator implementing the
rounding, never null.IllegalArgumentException - if no such rounding is registered using a
RoundingProviderSpi instance.public static MonetaryRounding getRounding(RoundingQuery roundingQuery)
MonetaryRounding using a possibly complex query.roundingQuery - The RoundingQuery that may contains arbitrary parameters to be
evaluated.MonetaryRounding, never null.IllegalArgumentException - if no such rounding is registered using a
RoundingProviderSpi instance.public static boolean isRoundingAvailable(String roundingName, String... providers)
MonetaryRounding is available given a roundingId.roundingName - The rounding identifier.providers - the providers and ordering to be used. By default providers and ordering as defined in
#getDefaultProviders is used.MonetaryRounding is available.IllegalArgumentException - if no such rounding is registered using a
RoundingProviderSpi instance.public static boolean isRoundingAvailable(CurrencyUnit currencyUnit, String... providers)
MonetaryRounding is available given a roundingId.currencyUnit - The currency, which determines the required scale. As RoundingMode,
by default, RoundingMode.HALF_UP is used.providers - the providers and ordering to be used. By default providers and ordering as defined in
#getDefaultProviders is used.MonetaryRounding is available.IllegalArgumentException - if no such rounding is registered using a
RoundingProviderSpi instance.public static boolean isRoundingAvailable(RoundingQuery roundingQuery)
MonetaryRounding matching the query is available.roundingQuery - The RoundingQuery that may contains arbitrary parameters to be
evaluated.MonetaryRounding is available.IllegalArgumentException - if no such rounding is registered using a
RoundingProviderSpi instance.public static Collection<MonetaryRounding> getRoundings(RoundingQuery roundingQuery)
MonetaryRounding instances using a possibly complex queryroundingQuery - The RoundingQuery that may contains arbitrary parameters to be
evaluated.MonetaryRounding instances matching the query, never null.public static Set<String> getRoundingNames(String... providers)
providers - the providers and ordering to be used. By default providers and ordering as defined in
#getDefaultProviders is used.null.public static <T extends MonetaryAmount> MonetaryAmountFactory<T> getAmountFactory(Class<T> amountType)
MonetaryAmountFactory for the given MonetaryAmount implementation
type.amountType - MonetaryAmount implementation type, nor null.MonetaryAmountFactory, never null.MonetaryException - if no MonetaryAmountFactory targeting the given MonetaryAmount
implementation class is registered.public static MonetaryAmountFactory<?> getDefaultAmountFactory()
MonetaryAmountFactory as defined by
MonetaryAmountsSingletonSpi.getDefaultAmountFactory().MonetaryAmountFactory corresponding to default amount type,
never null.MonetaryException - if no MonetaryAmountFactory targeting the default amount type
implementation class is registered.public static Collection<MonetaryAmountFactory<?>> getAmountFactories()
MonetaryAmount implementation classes that are
accessible from this MonetaryAmount singleton.MonetaryAmount implementation classes that have
corresponding MonetaryAmountFactory instances provided, never nullpublic static Collection<Class<? extends MonetaryAmount>> getAmountTypes()
MonetaryAmount implementation classes that are
accessible from this MonetaryAmount singleton.MonetaryAmount implementation classes that have
corresponding MonetaryAmountFactory instances provided, never nullpublic static Class<? extends MonetaryAmount> getDefaultAmountType()
MonetaryAmount implementation class that is
accessible from this MonetaryAmount singleton.MonetaryAmount implementation class, never nullpublic static MonetaryAmountFactory getAmountFactory(MonetaryAmountFactoryQuery query)
query - the factory query, not null.public static Collection<MonetaryAmountFactory<?>> getAmountFactories(MonetaryAmountFactoryQuery query)
query - the factory query, not null.public static boolean isAvailable(MonetaryAmountFactoryQuery query)
.MonetaryAmountFactory.query - the factory query, not null.MonetaryAmountFactory matches the query.public static CurrencyUnit getCurrency(String currencyCode, String... providers)
CurrencyProviderSpi instances registered
with the Bootstrap.currencyCode - the ISO currency code, not null.providers - the (optional) specification of providers to consider.CurrencyUnit instance.UnknownCurrencyException - if no such currency exists.public static CurrencyUnit getCurrency(Locale locale, String... providers)
Locale. Currencies are
available as provided by CurrencyProviderSpi instances registered
with the Bootstrap.locale - the target Locale, typically representing an ISO
country, not null.providers - the (optional) specification of providers to consider.CurrencyUnit instance.UnknownCurrencyException - if no such currency exists.public static Set<CurrencyUnit> getCurrencies(Locale locale, String... providers)
Locale. Currencies are
available as provided by CurrencyProviderSpi instances registered
with the Bootstrap.locale - the target Locale, typically representing an ISO
country, not null.providers - the (optional) specification of providers to consider.CurrencyUnit instance.UnknownCurrencyException - if no such currency exists.public static boolean isCurrencyAvailable(String code, String... providers)
CurrencyUnit instance is defined, i.e.
accessible from getCurrency(String, String...).code - the currency code, not null.providers - the (optional) specification of providers to consider.true if getCurrency(String, java.lang.String...)
would return a result for the given code.public static boolean isCurrencyAvailable(Locale locale, String... providers)
CurrencyUnit instance is
defined, i.e. accessible from getCurrency(String, String...).locale - the target Locale, not null.providers - the (optional) specification of providers to consider.true if getCurrencies(Locale, String...) would return a
result containing a currency with the given code.public static Collection<CurrencyUnit> getCurrencies(String... providers)
providers - the (optional) specification of providers to consider.public static CurrencyUnit getCurrency(CurrencyQuery query)
query - The CurrencyQuery, not null.public static Collection<CurrencyUnit> getCurrencies(CurrencyQuery query)
query - The CurrencyQuery, not null.public static Set<String> getCurrencyProviderNames()
public static List<String> getDefaultCurrencyProviderChain()
Copyright © 2012–2016 JSR 354 - Expert Group. All rights reserved.