- All Known Implementing Classes:
DefaultMonetaryRoundingsSingletonSpi
public interface MonetaryRoundingsSingletonSpi
This class models the accessor for rounding instances, modeled as
MonetaryOperator.
This class is thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionAccess a list of the currently registered default providers.Creates aMonetaryRoundingthat can be added asMonetaryOperatorto chained calculations.Allows to access the names of the current registered rounding providers.default MonetaryRoundinggetRounding(String roundingName, String... providers) Access aMonetaryRoundingusing the rounding name.default MonetaryRoundinggetRounding(CurrencyUnit currencyUnit, String... providers) Access aMonetaryRoundingfor roundingMonetaryAmountinstances given a currency.default MonetaryRoundinggetRounding(RoundingQuery query) Query a specific rounding with the given query.getRoundingNames(String... providers) Allows to access the names of the current defined roundings.getRoundings(RoundingQuery query) Execute a query forMonetaryRounding.default booleanisRoundingAvailable(String roundingId, String... providers) Checks if aMonetaryRoundingis available given a roundingId.default booleanisRoundingAvailable(CurrencyUnit currencyUnit, String... providers) Checks if aMonetaryRoundingis available given aCurrencyUnit.default booleanisRoundingAvailable(RoundingQuery query) Checks if anyMonetaryRoundingis matching the given query.
-
Method Details
-
getRoundingNames
Allows to access the names of the current defined roundings.- Parameters:
providers- the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.- Returns:
- the set of custom rounding ids, never
null.
-
getProviderNames
Allows to access the names of the current registered rounding providers.- Returns:
- the set of provider names, never
null.
-
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 provider names in order, defining the provider chain.
The default provider chain configured in
javamoney.propertiesis used. - See Also:
-
getRoundings
Execute a query forMonetaryRounding. This allows to model more complex used cases, such as historic or special roundings.- Parameters:
query- the query to be expected, not null.- Returns:
- the roundings found, never null.
-
getDefaultRounding
MonetaryRounding getDefaultRounding()Creates aMonetaryRoundingthat can be added asMonetaryOperatorto chained calculations. The instance must lookup the concreteMonetaryRoundinginstance from theMonetaryRoundingsSingletonSpibased on the inputMonetaryAmount'sCurrencyUnit.- Returns:
- the (shared) default rounding instance.
-
getRounding
Access aMonetaryRoundingfor roundingMonetaryAmountinstances given a currency.- Parameters:
currencyUnit- The currency, which determines the required precision. AsRoundingMode, by default,RoundingMode.HALF_UPis sued.providers- the optional provider list and ordering to be used- Returns:
- a new instance
MonetaryOperatorimplementing the rounding, nevernull. - Throws:
MonetaryException- if no such rounding could be provided.
-
getRounding
Access aMonetaryRoundingusing the rounding name.- Parameters:
roundingName- The rounding name, not null.providers- the optional provider list and ordering to be used- Returns:
- the corresponding
MonetaryOperatorimplementing the rounding, nevernull. - Throws:
IllegalArgumentException- if no such rounding is registered using aRoundingProviderSpiinstance.
-
getRounding
Query a specific rounding with the given query. If multiple roundings match the query the first one is selected, since the query allows to determine the providers and their ordering by settingAbstractQuery.getProviderNames().- Parameters:
query- the rounding query, not null.- Returns:
- the rounding found, or null, if no rounding matches the query.
-
isRoundingAvailable
Checks if anyMonetaryRoundingis matching the given query.- Parameters:
query- the rounding query, not null.- Returns:
- true, if at least one rounding matches the query.
-
isRoundingAvailable
Checks if aMonetaryRoundingis available given a roundingId.- Parameters:
roundingId- The rounding identifier.providers- the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.- Returns:
- true, if a corresponding
MonetaryRoundingis available. - Throws:
IllegalArgumentException- if no such rounding is registered using aRoundingProviderSpiinstance.
-
isRoundingAvailable
Checks if aMonetaryRoundingis available given aCurrencyUnit.- Parameters:
currencyUnit- The currency, which determines the required precision. AsRoundingMode, by default,RoundingMode.HALF_UPis used.providers- the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.- Returns:
- true, if a corresponding
MonetaryRoundingis available. - Throws:
IllegalArgumentException- if no such rounding is registered using aRoundingProviderSpiinstance.
-