- java.lang.Object
-
- javax.money.AbstractContext
-
- javax.money.AbstractQuery
-
- javax.money.RoundingQuery
-
- All Implemented Interfaces:
java.io.Serializable,CurrencySupplier
public final class RoundingQuery extends AbstractQuery implements CurrencySupplier
Query for accessing instances ofMonetaryRounding. In general it is determined by the implementation, what roundings are provided. Nevertheless the following queries must be supported:- Accessing roundings using rounding names and/or regular expressions.
- Accessing mathematical rounding by setting a scale and (optionally) a
MathContextas additional generic attribute. - Accessing default roundings for a
CurrencyUnit. This method should return the most appropriate rounding for a currency. If no currency specific rounding is available, it should return a rounding withscale==currency .getDefaultFractionUnits(), java.math.RoundingMode = RoundingMode.HALF_EVEN.
This class is immutable, thread-safe and serializable.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.money.AbstractQuery
KEY_QUERY_PROVIDERS, KEY_QUERY_TARGET_TYPE, KEY_QUERY_TIMESTAMP
-
Fields inherited from class javax.money.AbstractContext
KEY_PROVIDER
-
-
Method Summary
Modifier and Type Method Description CurrencyUnitgetCurrency()Sets the target CurrencyUnit.java.lang.StringgetRoundingName()Gets the target rounding name.java.lang.IntegergetScale()Gets the target scale.RoundingQueryBuildertoBuilder()Creates a new builder instances, initialized with the data from this one.-
Methods inherited from class javax.money.AbstractQuery
getProviderNames, getTargetType
-
-
-
-
Method Detail
-
getRoundingName
public java.lang.String getRoundingName()
Gets the target rounding name. This method allows to access theMonetaryRoundinginstances 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.- Returns:
- the rounding id or null.
-
getScale
public java.lang.Integer getScale()
Gets the target scale. This allows to define the scale required. If not specified as additional attribute, by default, RoundingMode.HALF_EVEN is used hereby.- Returns:
- the target scale or null.
-
getCurrency
public CurrencyUnit getCurrency()
Sets the target CurrencyUnit. Typically this determines all other properties, such as scale and the concrete rounding algorithm. With rounding names, depending on the implementation, additional sub-selections are possible. Similarly additional attributes can be used to select special rounding instances, e.g. for cash rounding.- Specified by:
getCurrencyin interfaceCurrencySupplier- Returns:
- the CurrencyUnit, or null.
-
toBuilder
public RoundingQueryBuilder toBuilder()
Creates a new builder instances, initialized with the data from this one.- Returns:
- a new
RoundingQueryBuilderinstance, never null.
-
-