Interface MicroPropsGenerator
- All Known Implementing Classes:
LongNameHandler,LongNameMultiplexer,MicroProps,MixedUnitLongNameHandler,MultiplierFormatHandler,MutablePatternModifier,MutablePatternModifier.ImmutablePatternModifier,UnitConversionHandler,UsagePrefsHandler
processQuantity(org.graalvm.shadowed.com.ibm.icu.impl.number.DecimalQuantity) method performs the final step in the number
processing pipeline: it uses the quantity to generate a finalized MicroProps, which can be
used to render the number to output.
In other words, this interface is used for the parts of number processing that are quantity-dependent.
In order to allow for multiple different objects to all mutate the same MicroProps, a "chain" of
MicroPropsGenerators are linked together, and each one is responsible for manipulating a certain
quantity-dependent part of the MicroProps. At the top of the linked list is a base instance of
MicroProps with properties that are not quantity-dependent. Each element in the linked list
calls processQuantity(org.graalvm.shadowed.com.ibm.icu.impl.number.DecimalQuantity) on its "parent", then does its work, and then returns the result.
This chain of MicroPropsGenerators is typically constructed by NumberFormatterImpl::macrosToMicroGenerator() when constructing a NumberFormatter.
A class implementing MicroPropsGenerator looks something like this:
class Foo implements MicroPropsGenerator {
private final MicroPropsGenerator parent;
public Foo(MicroPropsGenerator parent) {
this.parent = parent;
}
@Override
public MicroProps processQuantity(DecimalQuantity quantity) {
MicroProps micros = this.parent.processQuantity(quantity);
// Perform manipulations on micros and/or quantity
return micros;
}
}
-
Method Summary
Modifier and TypeMethodDescriptionprocessQuantity(DecimalQuantity quantity) Considers the givenDecimalQuantity, optionally mutates it, and returns aMicroProps.
-
Method Details
-
processQuantity
Considers the givenDecimalQuantity, optionally mutates it, and returns aMicroProps.- Parameters:
quantity- The quantity for consideration and optional mutation.- Returns:
- A MicroProps instance resolved for the quantity.
-