Top Description Fields Constructors Methods
org.javamoney.moneta.spi

pack-priv final Class DefaultRounding

extends Object
implements MonetaryRounding, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.money.MonetaryRounding, javax.money.MonetaryOperator
Imports
javax.money.*, java.io.Serializable, java.math.BigDecimal, .RoundingMode, java.util.Objects

Implementation class providing rounding javax.money.MonetaryOperator instances for CurrencyUnit instances. modeling rounding based on standard JDK math, a scale and RoundingMode.

This class is thread safe.

Authors
Anatole Tresch, Werner Keil
See Also
RoundingMode

Field Summary

Modifier and TypeField and Description
private final RoundingContext
private static final String
PROVCLASS_KEY

The provider class key to be used.

private static final String
SCALE_KEY

The scale key to be used.

private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
DefaultRounding(int scale, RoundingMode
The java.math.RoundingMode to be used, not null.
roundingMode
)

Creates an rounding instance.

pack-priv
DefaultRounding(CurrencyUnit
The currency, which determines the required precision. As RoundingMode, by default, RoundingMode#HALF_UP is used.
currency
,
RoundingMode roundingMode)

Creates an DefaultRounding for rounding MonetaryAmount instances given a currency.

Method Summary

Modifier and TypeMethod and Description
public MonetaryAmount
apply(MonetaryAmount 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

contextback to summary
private final RoundingContext context

The RoundingMode used.

PROVCLASS_KEYback to summary
private static final String PROVCLASS_KEY

The provider class key to be used.

SCALE_KEYback to summary
private static final String SCALE_KEY

The scale key to be used.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DefaultRoundingback to summary
pack-priv DefaultRounding(int scale, RoundingMode roundingMode)

Creates an rounding instance.

Parameters
roundingMode:RoundingMode

The java.math.RoundingMode to be used, not null.

DefaultRoundingback to summary
pack-priv DefaultRounding(CurrencyUnit currency, RoundingMode roundingMode)

Creates an DefaultRounding for rounding MonetaryAmount instances given a currency.

Parameters
currency:CurrencyUnit

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

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.

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
Annotations
@Override