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

pack-priv final Class DefaultCashRounding

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 cash rounding javax.money.MonetaryOperator instances for CurrencyUnit instances. modeling rounding based on minimal minor units available for cash payments.

This class is thread safe.

Author
Anatole Tresch

Field Summary

Modifier and TypeField and Description
private static final String
CASHROUNDING_KEY

The cash rounding flag key to be used.

private RoundingContext
private static final String
MINMINORS_KEY

The scale key to be used.

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
DefaultCashRounding(int
The target scale.
scale
,
RoundingMode
The RoundingMode to be used, not null.
roundingMode
,
int minimalMinors)

Creates an rounding instance.

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

Creates an DefaultCashRounding for rounding MonetaryAmount instances given a currency.

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

Creates an MonetaryOperator 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

CASHROUNDING_KEYback to summary
private static final String CASHROUNDING_KEY

The cash rounding flag key to be used.

contextback to summary
private RoundingContext context
MINMINORS_KEYback to summary
private static final String MINMINORS_KEY

The scale key to be 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

DefaultCashRoundingback to summary
pack-priv DefaultCashRounding(int scale, RoundingMode roundingMode, int minimalMinors)

Creates an rounding instance.

Parameters
scale:int

The target scale.

roundingMode:RoundingMode

The RoundingMode to be used, not null.

DefaultCashRoundingback to summary
pack-priv DefaultCashRounding(CurrencyUnit currency, RoundingMode roundingMode, int minimalMinors)

Creates an DefaultCashRounding 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.

DefaultCashRoundingback to summary
pack-priv DefaultCashRounding(CurrencyUnit currency, int minimalMinors)

Creates an MonetaryOperator 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