Class RoundingQuery

All Implemented Interfaces:, 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 with scale==currency .getDefaultFractionUnits(), java.math.RoundingMode = RoundingMode.HALF_EVEN.
All other roundings including cash rounding and historical roundings are optional.

This class is immutable, thread-safe and serializable.

See Also:
Serialized Form
  • Method Details

    • getRoundingName

      public java.lang.String getRoundingName()
      Gets the target rounding name. This method allows to access the MonetaryRounding 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.
      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.
      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:
      getCurrency in interface CurrencySupplier
      the CurrencyUnit, or null.
    • toBuilder

      public RoundingQueryBuilder toBuilder()
      Creates a new builder instances, initialized with the data from this one.
      a new RoundingQueryBuilder instance, never null.