Class PluralOperands

java.lang.Object
com.lokalized.PluralOperands

@Immutable public final class PluralOperands extends Object
Unicode CLDR plural operands for cardinality and ordinality evaluation.

Most applications should use Cardinality.forNumber(Number, java.util.Locale) or Ordinality.forNumber(Number, java.util.Locale). Use this type when the displayed number has details that are not fully represented by the Java Number, such as an explicitly visible decimal count or a compact-decimal exponent.

CLDR plural-category evaluation uses the absolute numeric value exposed by getNumber(). When an instance is used in an alternative expression's ordinary numeric comparison, Lokalized instead preserves the sign of the source number supplied to forNumber(Number).

Supported number implementations are BigDecimal, BigInteger, the boxed JDK numeric types (Byte, Short, Integer, Long, Float, and Double), and the JDK atomic numeric types (AtomicInteger, AtomicLong, LongAdder, DoubleAdder, LongAccumulator, and DoubleAccumulator). Atomic values are sampled once when PluralOperands.Builder.build() executes. Integral values are converted exactly. Float and Double values use their canonical decimal representation rather than the exact binary floating-point value. Non-finite floating-point values and unlisted Number implementations are rejected; callers with another numeric representation should convert it to a BigDecimal explicitly. Builders use TranslationRuntimeLimits.defaults() unless PluralOperands.Builder.runtimeLimits(TranslationRuntimeLimits) supplies different limits. This is also how callers opt up from the defaults to the hard ceilings exposed below.

Since:
3.0.0
Author:
Mark Allen