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 of
MonetaryRounding
. 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
MathContext
as 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
-
Method Summary
Modifier and Type Method Description CurrencyUnit
getCurrency()
Sets the target CurrencyUnit.java.lang.String
getRoundingName()
Gets the target rounding name.java.lang.Integer
getScale()
Gets the target scale.RoundingQueryBuilder
toBuilder()
Creates a new builder instances, initialized with the data from this one.
-
Method Details
-
getRoundingName
public java.lang.String getRoundingName()Gets the target rounding name. 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.- 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
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:
getCurrency
in interfaceCurrencySupplier
- Returns:
- the CurrencyUnit, or null.
-
toBuilder
Creates a new builder instances, initialized with the data from this one.- Returns:
- a new
RoundingQueryBuilder
instance, never null.
-