- java.lang.Object
-
- javax.money.AbstractContextBuilder<MonetaryContextBuilder,MonetaryContext>
-
- javax.money.MonetaryContextBuilder
-
public final class MonetaryContextBuilder extends AbstractContextBuilder<MonetaryContextBuilder,MonetaryContext>
Builder class for creating new instances ofMonetaryContextadding detailed information about aMonetaryAmountinstance.Note this class is NOT thread-safe.
- See Also:
MonetaryAmount.getContext()
-
-
Method Summary
Modifier and Type Method Description MonetaryContextbuild()Creates a new instance ofMonetaryAmountFactoryQuery.static MonetaryContextBuilderof()Creates a new builder, hereby the target implementation type is required.static MonetaryContextBuilderof(java.lang.Class<? extends MonetaryAmount> amountType)Creates a new builder, hereby the target implementation type is required.static MonetaryContextBuilderof(MonetaryContext monetaryContext)Creates a new builder, using an existingMonetaryContextas a template.MonetaryContextBuildersetAmountType(java.lang.Class<? extends MonetaryAmount> amountType)Set the MonetaryAmount implementation class.MonetaryContextBuildersetFixedScale(boolean fixedScale)Set the flag if the scale should fixed.MonetaryContextBuildersetMaxScale(int maxScale)Set the maximal scale to be supported.MonetaryContextBuildersetPrecision(int precision)Set the required precision.-
Methods inherited from class javax.money.AbstractContextBuilder
importContext, importContext, removeAttributes, set, set, set, set, set, set, set, set, set, setProviderName, toString
-
-
-
-
Method Detail
-
setMaxScale
public MonetaryContextBuilder setMaxScale(int maxScale)
Set the maximal scale to be supported.- Parameters:
maxScale- the max scale, >= 0.- Returns:
- this builder for chaining.
-
setPrecision
public MonetaryContextBuilder setPrecision(int precision)
Set the required precision.- Parameters:
precision- the precision, >= 0, 0 meaning unlimited.- Returns:
- this builder for chaining.
-
setFixedScale
public MonetaryContextBuilder setFixedScale(boolean fixedScale)
Set the flag if the scale should fixed.- Parameters:
fixedScale- the fixed scale flag.- Returns:
- this builder for chaining.
-
setAmountType
public MonetaryContextBuilder setAmountType(java.lang.Class<? extends MonetaryAmount> amountType)
Set the MonetaryAmount implementation class.- Parameters:
amountType- the target amount type, not null.- Returns:
- the implementation class of the containing amount instance, never null.
- See Also:
MonetaryAmount.getContext()
-
build
public MonetaryContext build()
Creates a new instance ofMonetaryAmountFactoryQuery.- Specified by:
buildin classAbstractContextBuilder<MonetaryContextBuilder,MonetaryContext>- Returns:
- a new
MonetaryAmountFactoryQueryinstance.
-
of
public static MonetaryContextBuilder of()
Creates a new builder, hereby the target implementation type is required. This can be used to explicitly acquire a specific amount type and additionally configure the amount factory with the attributes in this query.- Returns:
- a new
MonetaryContextBuilderinstance, never null.
-
of
public static MonetaryContextBuilder of(MonetaryContext monetaryContext)
Creates a new builder, using an existingMonetaryContextas a template.- Returns:
- a new
MonetaryContextBuilderinstance, never null.
-
of
public static MonetaryContextBuilder of(java.lang.Class<? extends MonetaryAmount> amountType)
Creates a new builder, hereby the target implementation type is required. This can be used to explicitly acquire a specific amount type and additionally configure the amount factory with the attributes in this query.- Parameters:
amountType- the target amount type, not null.- Returns:
- a new
MonetaryContextBuilderinstance, never null.
-
-