All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.money.MonetaryContextBuilder Maven / Gradle / Ivy

Go to download

JSR 354 provides an API for representing, transporting, and performing comprehensive calculations with Money and Currency. This module provides a forward compatible backport of the API.

There is a newer version: 1.0.4
Show newest version
/*
 * CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU
 * ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS OF THIS
 * AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF
 * THE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE" BUTTON AT THE
 * BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency API ("Specification") Copyright
 * (c) 2012-2013, Credit Suisse All rights reserved.
 */
package javax.money;


/**
 * Builder class for creating new instances of {@link MonetaryContext} adding detailed information
 * about a {@link MonetaryAmount} instance.
 * 

* Note this class is NOT thread-safe. * * @see MonetaryAmount#getContext() */ public final class MonetaryContextBuilder extends AbstractContextBuilder { private MonetaryContextBuilder(MonetaryContext monetaryContext) { importContext(monetaryContext); } /** * 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. * * @param amountType the target amount type, not null. */ MonetaryContextBuilder(Class amountType) { set(MonetaryContext.AMOUNT_TYPE, amountType); } /** * Set the maximal scale to be supported. * * @param maxScale the max scale, >= 0. * @return this builder for chaining. */ public MonetaryContextBuilder setMaxScale(int maxScale) { return set("maxScale", maxScale); } /** * Set the required precision. * * @param precision the precision, >= 0, 0 meaning unlimited. * @return this builder for chaining. */ public MonetaryContextBuilder setPrecision(int precision) { return set("precision", precision); } /** * Set the flag if the scale should fixed. * * @param fixedScale the fixed scale flag. * @return this builder for chaining. */ public MonetaryContextBuilder setFixedScale(boolean fixedScale) { return set("fixedScale", fixedScale); } /** * Set the MonetaryAmount implementation class. * * @return the implementation class of the containing amount instance, never null. * @see MonetaryAmount#getContext() */ public MonetaryContextBuilder setAmountType(Class amountType) { return set(MonetaryContext.AMOUNT_TYPE, amountType); } /** * Creates a new instance of {@link MonetaryAmountFactoryQuery}. * * @return a new {@link MonetaryAmountFactoryQuery} instance. */ public MonetaryContext build() { return new MonetaryContext(this); } /** * 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. * * @return a new {@link MonetaryContextBuilder} instance, never null. */ public static MonetaryContextBuilder of() { return of(MonetaryAmount.class); } /** * Creates a new builder, using an existing {@link MonetaryContext} as a template. * * @return a new {@link MonetaryContextBuilder} instance, never null. */ public static MonetaryContextBuilder of(MonetaryContext monetaryContext) { return new MonetaryContextBuilder(monetaryContext); } /** * 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. * * @param amountType the target amount type, not null. * @return a new {@link MonetaryContextBuilder} instance, never null. */ public static MonetaryContextBuilder of(Class amountType) { return new MonetaryContextBuilder(amountType); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy