java.lang.Object
javax.money.AbstractContext
javax.money.RoundingContext
- All Implemented Interfaces:
Serializable,CurrencySupplier
public final class RoundingContext
extends AbstractContext
implements Serializable, CurrencySupplier
This class models the spec/configuration for a rounding, modeled as
MonetaryRounding in a
platform independent way. Each RoundingContext instance hereby has a roundingId, which links
to the RoundingProviderSpi that must of the according rounding instance. The
default roundingId is default.
A RoundingContext can take up arbitrary attributes that must be documented by the
RoundingProviderSpi implementations.
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:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringAttribute key used for the rounding name.private static final longFields inherited from class javax.money.AbstractContext
data, KEY_PROVIDER -
Constructor Summary
ConstructorsConstructorDescriptionRoundingContext(RoundingContextBuilder builder) Constructor, used from theRoundingContextBuilder. -
Method Summary
Modifier and TypeMethodDescriptionGet the basicCurrencyUnit, which is based for this rounding type.Get the (custom) rounding id.Allows to convert a instance into the correspondingCurrencyContextBuilder, which allows to change the values and of anotherCurrencyContextinstance.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
KEY_ROUNDING_NAME
Attribute key used for the rounding name.- See Also:
-
-
Constructor Details
-
RoundingContext
RoundingContext(RoundingContextBuilder builder) Constructor, used from theRoundingContextBuilder.- Parameters:
builder- the corresponding builder, not null.
-
-
Method Details
-
getRoundingName
Get the (custom) rounding id.- Returns:
- the rounding id, or null.
-
getCurrency
Get the basicCurrencyUnit, which is based for this rounding type.- Specified by:
getCurrencyin interfaceCurrencySupplier- Returns:
- the target CurrencyUnit, or null.
-
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.
-