Top Description Methods
javax.money.spi

public Interface MonetaryRoundingsSingletonSpi

Known Direct Implementers
javax.money.DefaultMonetaryRoundingsSingletonSpi
Imports
javax.money.*, java.util.Collection, .List, .Optional, .Set

This class models the accessor for rounding instances, modeled as javax.money.MonetaryOperator.

This class is thread-safe.

Authors
Anatole Tresch, Werner Keil

Method Summary

Modifier and TypeMethod and Description
public List<String>

Returns:

the provider names in order, defining the provider chain. The default provider chain configured in javamoney.properties is used.
getDefaultProviderChain
()

Access a list of the currently registered default providers.

public MonetaryRounding

Returns:

the (shared) default rounding instance.
getDefaultRounding
()

Creates a MonetaryRounding that can be added as javax.money.MonetaryOperator to chained calculations.

public Set<String>

Returns:

the set of provider names, never null.
getProviderNames
()

Allows to access the names of the current registered rounding providers.

public default MonetaryRounding

Returns:

a new instance javax.money.MonetaryOperator implementing the rounding, never null.
getRounding
(CurrencyUnit
The currency, which determines the required precision. As java.math.RoundingMode, by default, java.math.RoundingMode#HALF_UP is sued.
currencyUnit
,
String...
the optional provider list and ordering to be used
providers
)

Access a javax.money.MonetaryRounding for rounding javax.money.MonetaryAmount instances given a currency.

public default MonetaryRounding

Returns:

the corresponding javax.money.MonetaryOperator implementing the rounding, never null.
getRounding
(String
The rounding name, not null.
roundingName
,
String...
the optional provider list and ordering to be used
providers
)

Access a javax.money.MonetaryRounding using the rounding name.

public default MonetaryRounding

Returns:

the rounding found, or null, if no rounding matches the query.
getRounding
(RoundingQuery
the rounding query, not null.
query
)

Query a specific rounding with the given query.

public Set<String>

Returns:

the set of custom rounding ids, never null.
getRoundingNames
(String...
the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.
providers
)

Allows to access the names of the current defined roundings.

public Collection<MonetaryRounding>

Returns:

the roundings found, never null.
getRoundings
(RoundingQuery
the query to be expected, not null.
query
)

Execute a query for javax.money.MonetaryRounding.

public default boolean

Returns:

true, if at least one rounding matches the query.
isRoundingAvailable
(RoundingQuery
the rounding query, not null.
query
)

Checks if any javax.money.MonetaryRounding is matching the given query.

public default boolean

Returns:

true, if a corresponding javax.money.MonetaryRounding is available.
isRoundingAvailable
(String
The rounding identifier.
roundingId
,
String...
the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.
providers
)

Checks if a MonetaryRounding is available given a roundingId.

public default boolean

Returns:

true, if a corresponding javax.money.MonetaryRounding is available.
isRoundingAvailable
(CurrencyUnit
The currency, which determines the required precision. As java.math.RoundingMode, by default, java.math.RoundingMode#HALF_UP is used.
currencyUnit
,
String...
the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.
providers
)

Checks if a MonetaryRounding is available given a javax.money.CurrencyUnit.

Method Detail

getDefaultProviderChainback to summary
public 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:List<String>

the provider names in order, defining the provider chain. The default provider chain configured in javamoney.properties is used.

See Also
javax.money.RoundingQueryBuilder
getDefaultRoundingback to summary
public MonetaryRounding getDefaultRounding()

Creates a MonetaryRounding that can be added as javax.money.MonetaryOperator to chained calculations. The instance must lookup the concrete javax.money.MonetaryRounding instance from the javax.money.spi.MonetaryRoundingsSingletonSpi based on the input javax.money.MonetaryAmount's javax.money.CurrencyUnit.

Returns:MonetaryRounding

the (shared) default rounding instance.

getProviderNamesback to summary
public Set<String> getProviderNames()

Allows to access the names of the current registered rounding providers.

Returns:Set<String>

the set of provider names, never null.

getRoundingback to summary
public default MonetaryRounding getRounding(CurrencyUnit currencyUnit, String... providers)

Access a javax.money.MonetaryRounding for rounding javax.money.MonetaryAmount instances given a currency.

Parameters
currencyUnit:CurrencyUnit

The currency, which determines the required precision. As java.math.RoundingMode, by default, java.math.RoundingMode#HALF_UP is sued.

providers:String[]

the optional provider list and ordering to be used

Returns:MonetaryRounding

a new instance javax.money.MonetaryOperator implementing the rounding, never null.

Exceptions
MonetaryException:
if no such rounding could be provided.
getRoundingback to summary
public default MonetaryRounding getRounding(String roundingName, String... providers)

Access a javax.money.MonetaryRounding using the rounding name.

Parameters
roundingName:String

The rounding name, not null.

providers:String[]

the optional provider list and ordering to be used

Returns:MonetaryRounding

the corresponding javax.money.MonetaryOperator implementing the rounding, never null.

Exceptions
IllegalArgumentException:
if no such rounding is registered using a javax.money.spi.RoundingProviderSpi instance.
getRoundingback to summary
public default MonetaryRounding getRounding(RoundingQuery query)

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 setting RoundingQuery#getProviderNames().

Parameters
query:RoundingQuery

the rounding query, not null.

Returns:MonetaryRounding

the rounding found, or null, if no rounding matches the query.

getRoundingNamesback to summary
public Set<String> getRoundingNames(String... providers)

Allows to access the names of the current defined roundings.

Parameters
providers:String[]

the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.

Returns:Set<String>

the set of custom rounding ids, never null.

getRoundingsback to summary
public Collection<MonetaryRounding> getRoundings(RoundingQuery query)

Execute a query for javax.money.MonetaryRounding. This allows to model more complex used cases, such as historic or special roundings.

Parameters
query:RoundingQuery

the query to be expected, not null.

Returns:Collection<MonetaryRounding>

the roundings found, never null.

isRoundingAvailableback to summary
public default boolean isRoundingAvailable(RoundingQuery query)

Checks if any javax.money.MonetaryRounding is matching the given query.

Parameters
query:RoundingQuery

the rounding query, not null.

Returns:boolean

true, if at least one rounding matches the query.

isRoundingAvailableback to summary
public default boolean isRoundingAvailable(String roundingId, String... providers)

Checks if a MonetaryRounding is available given a roundingId.

Parameters
roundingId:String

The rounding identifier.

providers:String[]

the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.

Returns:boolean

true, if a corresponding javax.money.MonetaryRounding is available.

Exceptions
IllegalArgumentException:
if no such rounding is registered using a RoundingProviderSpi instance.
isRoundingAvailableback to summary
public default boolean isRoundingAvailable(CurrencyUnit currencyUnit, String... providers)

Checks if a MonetaryRounding is available given a javax.money.CurrencyUnit.

Parameters
currencyUnit:CurrencyUnit

The currency, which determines the required precision. As java.math.RoundingMode, by default, java.math.RoundingMode#HALF_UP is used.

providers:String[]

the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used.

Returns:boolean

true, if a corresponding javax.money.MonetaryRounding is available.

Exceptions
IllegalArgumentException:
if no such rounding is registered using a RoundingProviderSpi instance.