Class PluralOperands
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionHard ceiling for the absoluteBigDecimal.scale()accepted for a number used in plural operands or an alternative-expression numeric literal: 4,096.Hard ceiling for compact-decimal exponents accepted byPluralOperands.Builder.compactExponent(Integer): 4,096.Hard precision ceiling for a number used in plural operands or an alternative-expression numeric literal: 4,096.Hard ceiling for explicitly visible decimal places accepted byPluralOperands.Builder.visibleDecimalPlaces(Integer): 4,096. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object is equal to another one.static @NonNull PluralOperands.BuilderCreates a builder for CLDR plural operands backed by the given number.Gets the compact-decimal exponent used for the CLDRcandeoperands.Gets the absolute numeric value used for the CLDRnoperand.inthashCode()A hash code for this object.toString()Generates aStringrepresentation of this object.
-
Field Details
-
MAXIMUM_NUMBER_PRECISION
Hard precision ceiling for a number used in plural operands or an alternative-expression numeric literal: 4,096.- Since:
- 3.0.0
-
MAXIMUM_ABSOLUTE_NUMBER_SCALE
Hard ceiling for the absoluteBigDecimal.scale()accepted for a number used in plural operands or an alternative-expression numeric literal: 4,096.- Since:
- 3.0.0
-
MAXIMUM_VISIBLE_DECIMAL_PLACES
Hard ceiling for explicitly visible decimal places accepted byPluralOperands.Builder.visibleDecimalPlaces(Integer): 4,096.- Since:
- 3.0.0
-
MAXIMUM_COMPACT_EXPONENT
Hard ceiling for compact-decimal exponents accepted byPluralOperands.Builder.compactExponent(Integer): 4,096.- Since:
- 3.0.0
-
-
Method Details
-
forNumber
Creates a builder for CLDR plural operands backed by the given number.Negative numbers are evaluated using their absolute value. The supported
Numberimplementations and their conversion semantics are documented by this class.- Parameters:
number- the number that drives pluralization, not null- Returns:
- a plural-operands builder, not null
-
getNumber
Gets the absolute numeric value used for the CLDRnoperand.- Returns:
- the absolute numeric value, not null
-
getCompactExponent
Gets the compact-decimal exponent used for the CLDRcandeoperands.- Returns:
- the compact-decimal exponent, not null
-
toString
-
equals
-
hashCode
-