- java.lang.Object
-
- javax.money.AbstractContext
-
- javax.money.RoundingContext
-
- All Implemented Interfaces:
java.io.Serializable,CurrencySupplier
public final class RoundingContext extends AbstractContext implements java.io.Serializable, CurrencySupplier
This class models the spec/configuration for a rounding, modeled asMonetaryRoundingin a platform independent way. Each RoundingContext instance hereby has aroundingId, which links to theRoundingProviderSpithat must of the according rounding instance. The defaultroundingIdisdefault.A RoundingContext can take up arbitrary attributes that must be documented by the
RoundingProviderSpiimplementations.Examples for such additional attributes are
RoundingMode,MathContext, additional regional information, e.g. if a given rounding is targeting cash rounding.This class is immutable, serializable, thread-safe.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringKEY_ROUNDING_NAMEAttribute key used for the rounding name.private static longserialVersionUID-
Fields inherited from class javax.money.AbstractContext
data, KEY_PROVIDER
-
-
Constructor Summary
Constructors Constructor Description RoundingContext(RoundingContextBuilder builder)Constructor, used from theRoundingContextBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CurrencyUnitgetCurrency()Get the basicCurrencyUnit, which is based for this rounding type.java.lang.StringgetRoundingName()Get the (custom) rounding id.RoundingContextBuildertoBuilder()Allows to convert a instance into the correspondingCurrencyContextBuilder, which allows to change the values and of anotherCurrencyContextinstance.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
KEY_ROUNDING_NAME
static final java.lang.String KEY_ROUNDING_NAME
Attribute key used for the rounding name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RoundingContext
RoundingContext(RoundingContextBuilder builder)
Constructor, used from theRoundingContextBuilder.- Parameters:
builder- the corresponding builder, not null.
-
-
Method Detail
-
getRoundingName
public java.lang.String getRoundingName()
Get the (custom) rounding id.- Returns:
- the rounding id, or null.
-
getCurrency
public CurrencyUnit getCurrency()
Get the basicCurrencyUnit, which is based for this rounding type.- Specified by:
getCurrencyin interfaceCurrencySupplier- Returns:
- the target CurrencyUnit, or null.
-
toBuilder
public RoundingContextBuilder toBuilder()
Allows to convert a instance into the correspondingCurrencyContextBuilder, which allows to change the values and of anotherCurrencyContextinstance.- Returns:
- a new Builder instance, preinitialized with the values from this instance.
-
-