- All Implemented Interfaces:
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
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 with
scale==currency .getDefaultFractionUnits(), java.math.RoundingMode = RoundingMode.HALF_EVEN.
This class is immutable, thread-safe and serializable.
- See Also:
- Serialized Form
Fields inherited from class javax.money.AbstractQuery
KEY_QUERY_PROVIDERS, KEY_QUERY_TARGET_TYPE, KEY_QUERY_TIMESTAMP
Modifier and Type Method Description
getCurrency()Sets the target CurrencyUnit.
getRoundingName()Gets the target rounding name.
getScale()Gets the target scale.
toBuilder()Creates a new builder instances, initialized with the data from this one.
Methods inherited from class javax.money.AbstractContext
equals, get, get, getBoolean, getDouble, getFloat, getInt, getKeys, getLong, getProviderName, getText, getType, hashCode, isEmpty, toString
public java.lang.String getRoundingName()Gets the target rounding name. This method allows to access the
MonetaryRoundinginstances 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.
- the rounding id or null.
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.
- the target scale or null.
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.
public RoundingQueryBuilder toBuilder()Creates a new builder instances, initialized with the data from this one.
- a new
RoundingQueryBuilderinstance, never null.