Class NumberFn
- All Implemented Interfaces:
fluent.functions.FluentFunction,fluent.functions.FluentImplicit,fluent.functions.ImplicitFormatter
This is an Implicit function; it is called any time a number needs to be formatted to a String. When explicit, arguments to control formatting may be supplied.
As a selector, NUMBER() uses its argument to determine a CLDR plural category for the given locale. By default, this is type:"cardinal". Ordinal types are supported. If it is NOT desirable to produce a plural category from the number, type:"string" can be used; then an exact string pattern match (after formatting) will be performed.
When used as a selector, decimal formatting can (for some locales) make a difference as to plural selection. If this is important, consider using BigDecimal types, because the decimal representation can be more precisely controlled in contrast to double/float types. For integral types, this is generally less of a concern.
For a pattern-based alternative to number formatting, see the DecimalFn.
Supported format options:
useGrouping:"true" or "false". Whether to use a locale-appropriate numeric grouping separator.minimumIntegerDigits:Minimum number of digits to display before (left of) the decimal separator.minimumFractionDigits:Minimum number of digits to display after the decimal separator.maximumFractionDigits:Maximum number of digits to display after the decimal separator.style:Numeric display style "decimal", "currency", or "percent". "unit" style is NOT supported.
If either (or both) of the following format options are used, the minimumIntegerDigits, minimumFractionDigits, and maximumFractionDigits are ignored. The following options are:
minimumSignificantDigits:minimum significant digits (right of decimal separator) to display.maximumSignificantDigits:maximum significant digits (right of decimal separator) to display.
As a selector, the following options are supported (this will be otherwise be ignored):
-
type: "cardinal", "ordinal", or "string". No formatting is performed for cardinal or ordinal types, and a CLDR plural category will be selected as appropriate for the number and locale. For string types, formatting is applied then exact-string matching on selector variants occurs.
Unsupported options:
unitDisplaycurrencyDisplay
General notes:
- Extraneous options are ignored.
- Rounding mode: RoundingMode.HALF_UP
-
Nested Class Summary
Nested classes/interfaces inherited from interface fluent.functions.FluentImplicit
fluent.functions.FluentImplicit.Implicit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<fluent.types.FluentValue<?>>apply(fluent.functions.ResolvedParameters params, fluent.bundle.resolver.Scope scope) format(fluent.types.FluentValue<?> in, fluent.bundle.resolver.Scope scope) fluent.functions.FluentImplicit.Implicitid()List<fluent.types.FluentValue<?>>select(fluent.syntax.AST.SelectExpression selectExpression, fluent.functions.ResolvedParameters params, fluent.bundle.resolver.Scope scope) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface fluent.functions.FluentImplicit
name
-
Constructor Details
-
NumberFn
public NumberFn()
-
-
Method Details
-
id
public fluent.functions.FluentImplicit.Implicit id()- Specified by:
idin interfacefluent.functions.FluentImplicit
-
apply
public List<fluent.types.FluentValue<?>> apply(fluent.functions.ResolvedParameters params, fluent.bundle.resolver.Scope scope) - Specified by:
applyin interfacefluent.functions.FluentFunction
-
select
public List<fluent.types.FluentValue<?>> select(fluent.syntax.AST.SelectExpression selectExpression, fluent.functions.ResolvedParameters params, fluent.bundle.resolver.Scope scope) - Specified by:
selectin interfacefluent.functions.FluentFunction
-
format
- Specified by:
formatin interfacefluent.functions.ImplicitFormatter
-