java.lang.Object
javax.money.AbstractContextBuilder<B,C>
javax.money.AbstractQueryBuilder<RoundingQueryBuilder,RoundingQuery>
javax.money.RoundingQueryBuilder
public final class RoundingQueryBuilder extends AbstractQueryBuilder<RoundingQueryBuilder,RoundingQuery>
Builder used to construct new instances of RoundingQuery}.
Note this class is NOT thread-safe.
-
Method Summary
Modifier and Type Method Description RoundingQuery
build()
Creates a new instance ofRoundingQuery
.static RoundingQueryBuilder
of()
static RoundingQueryBuilder
of(RoundingQuery roundingQuery)
Creates a new RoundingQueryBuilder.RoundingQueryBuilder
setCurrency(CurrencyUnit currencyUnit)
Sets the targetCurrencyUnit
, which defines a rounding targeting a concreteCurrencyUnit
.RoundingQueryBuilder
setRoundingName(java.lang.String roundingName)
Sets the rounding names of theMonetaryRounding
instances.RoundingQueryBuilder
setScale(int scale)
Sets the target scale.Methods inherited from class javax.money.AbstractQueryBuilder
set, setProviderName, setProviderNames, setProviderNames, setTargetType
Methods inherited from class javax.money.AbstractContextBuilder
importContext, importContext, removeAttributes, set, set, set, set, set, set, set, set, set, toString
-
Method Details
-
setRoundingName
Sets the rounding names of theMonetaryRounding
instances. This method allows to access theMonetaryRounding
instances by passing a name, which most of the time identifies a certain rounding instance. Each entry is first matched as name on equality. If no instance with such a name exists, the value passed is interpreted as a regular expression to lookup roundings.- Parameters:
roundingName
- the (custom) rounding name expression, notnull
.- Returns:
- this instance for chaining
-
setScale
Sets the target scale. This allows to define the scale required. If not specified as additional attribute, by default, RoundingMode.HALF_EVEN is used hereby.- Parameters:
scale
- the target scale, >0.- Returns:
- this instance for chaining
-
setCurrency
Sets the targetCurrencyUnit
, which defines a rounding targeting a concreteCurrencyUnit
. Typically this determines all other properties, such as scale and the concrete rounding algorithm. With rounding names, depending on the implementation, additional subselections are possible. Similarly additional attributes can be used to select special rounding instances, e.g. for cash rounding.- Parameters:
currencyUnit
- the targetCurrencyUnit
not null.- Returns:
- this instance for chaining
-
build
Creates a new instance ofRoundingQuery
.- Specified by:
build
in classAbstractQueryBuilder<RoundingQueryBuilder,RoundingQuery>
- Returns:
- a new
RoundingQuery
instance.
-
of
- Returns:
- Creates a new RoundingQueryBuilder.
-
of
Creates a new RoundingQueryBuilder.- Parameters:
roundingQuery
- the rounding query, used as a template, not null.- Returns:
- a new
RoundingQueryBuilder
instance, never null.
-