Top Description Inners Fields Constructors Methods
javax.money

public final Class DefaultMonetaryRoundingsSingletonSpi

extends Object
implements MonetaryRoundingsSingletonSpi
Class Inheritance
All Implemented Interfaces
javax.money.spi.MonetaryRoundingsSingletonSpi
Imports
javax.money.spi.Bootstrap, .MonetaryRoundingsSingletonSpi, .RoundingProviderSpi, java.io.Serializable, java.util.ArrayList, .Collection, .Collections, .HashSet, .List, .Set, java.util.logging.Level, .Logger

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

This class is thread-safe.

Authors
Anatole Tresch, Werner Keil

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final MonetaryRounding
DEFAULT_ROUNDING

An adaptive rounding instance that transparently looks up the correct rounding.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public RoundingQueryBuilder

Returns:

the corresponding MonetaryOperator implementing the rounding.
createRoundingQueryBuilder
()

Creates an rounding instance using java.math.RoundingMode#UP rounding.

public List<String>

Returns:

the default provider list and ordering, not null.
getDefaultProviderChain
()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getDefaultProviderChain.

Get the default providers list to be used.
public MonetaryRounding

Returns:

the default rounding, never null.
getDefaultRounding
()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getDefaultRounding.

Get the default rounding, which delegates rounding dynamically depending on the current currency.
public Set<String>

Returns:

the names of all current registered providers, never null.
getProviderNames
()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getProviderNames.

Get the names of all current registered providers.
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, not null.
providers
)

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getRoundingNames.

Allows to access the identifiers of the current defined roundings.
public Collection<MonetaryRounding>

Returns:

the collection found, not null.
getRoundings
(RoundingQuery
the rounding query, not null.
query
)

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getRoundings.

Query all roundings matching the given RoundingQuery.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_ROUNDINGback to summary
private static final MonetaryRounding DEFAULT_ROUNDING

An adaptive rounding instance that transparently looks up the correct rounding.

Constructor Detail

DefaultMonetaryRoundingsSingletonSpiback to summary
public DefaultMonetaryRoundingsSingletonSpi()

Method Detail

createRoundingQueryBuilderback to summary
public RoundingQueryBuilder createRoundingQueryBuilder()

Creates an rounding instance using java.math.RoundingMode#UP rounding.

Returns:RoundingQueryBuilder

the corresponding MonetaryOperator implementing the rounding.

Exceptions
MonetaryException:
if no such rounding could be evaluated.
getDefaultProviderChainback to summary
public List<String> getDefaultProviderChain()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getDefaultProviderChain.

Get the default providers list to be used.

Returns:List<String>

the default provider list and ordering, not null.

Annotations
@Override
getDefaultRoundingback to summary
public MonetaryRounding getDefaultRounding()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getDefaultRounding.

Get the default rounding, which delegates rounding dynamically depending on the current currency.

Returns:MonetaryRounding

the default rounding, never null.

Annotations
@Override
getProviderNamesback to summary
public Set<String> getProviderNames()

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getProviderNames.

Get the names of all current registered providers.

Returns:Set<String>

the names of all current registered providers, never null.

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

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getRoundingNames.

Allows to access the identifiers 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, not null.

Returns:Set<String>

the set of custom rounding ids, never null.

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

Implements javax.money.spi.MonetaryRoundingsSingletonSpi.getRoundings.

Query all roundings matching the given RoundingQuery.

Parameters
query:RoundingQuery

the rounding query, not null.

Returns:Collection<MonetaryRounding>

the collection found, not null.

Annotations
@Override
javax.money back to summary

private final Class DefaultMonetaryRoundingsSingletonSpi.DefaultCurrencyRounding

extends Object
implements MonetaryRounding, Serializable
Class Inheritance
  • java.lang.Object
  • javax.money.DefaultMonetaryRoundingsSingletonSpi.DefaultCurrencyRounding
All Implemented Interfaces
java.io.Serializable, javax.money.MonetaryRounding, javax.money.MonetaryOperator

Default Rounding that rounds a MonetaryAmount based on the amount's CurrencyUnit.
Author
Anatole Tresch

Field Summary

Modifier and TypeField and Description
private static final RoundingContext
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MonetaryAmount
apply(MonetaryAmount
the amount to be operated on.
amount
)

Implements javax.money.MonetaryOperator.apply.

Applies the operator on the given amount.
public RoundingContext
getRoundingContext()

Implements javax.money.MonetaryRounding.getRoundingContext.

Access the rounding's context, which gives more details of the rounding instances such as
  • The rounding's name (required)
  • Its provider (required)
  • Its base currency
  • its scale and rounding mode
  • any other attributes useful to describe the rounding
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ROUNDING_CONTEXTback to summary
private static final RoundingContext ROUNDING_CONTEXT
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DefaultCurrencyRoundingback to summary
private DefaultCurrencyRounding()

Method Detail

applyback to summary
public MonetaryAmount apply(MonetaryAmount amount)

Implements javax.money.MonetaryOperator.apply.

Doc from javax.money.MonetaryOperator.apply.

Applies the operator on the given amount.

Parameters
amount:MonetaryAmount

the amount to be operated on.

Returns:MonetaryAmount

the applied amount.

Annotations
@Override
getRoundingContextback to summary
public RoundingContext getRoundingContext()

Implements javax.money.MonetaryRounding.getRoundingContext.

Doc from javax.money.MonetaryRounding.getRoundingContext.

Access the rounding's context, which gives more details of the rounding instances such as

  • The rounding's name (required)
  • Its provider (required)
  • Its base currency
  • its scale and rounding mode
  • any other attributes useful to describe the rounding
Returns:RoundingContext

the rounding's context, never null.

Annotations
@Override