Class UnitConversionHandler

  • All Implemented Interfaces:
    MicroPropsGenerator

    public class UnitConversionHandler
    extends java.lang.Object
    implements MicroPropsGenerator
    A MicroPropsGenerator which converts a measurement from one MeasureUnit to another. In particular, the output MeasureUnit may be a mixed unit. (The input unit may not be a mixed unit.)
    • Constructor Detail

      • UnitConversionHandler

        public UnitConversionHandler​(MeasureUnit targetUnit,
                                     MicroPropsGenerator parent)
        Parameters:
        targetUnit - Specifies the output MeasureUnit. The input MeasureUnit is derived from it: in case of a mixed unit, the biggest unit is taken as the input unit. If not a mixed unit, the input unit will be the same as the output unit and no unit conversion takes place.
        parent - The parent MicroPropsGenerator.
    • Method Detail

      • processQuantity

        public MicroProps processQuantity​(DecimalQuantity quantity)
        Obtains the appropriate output values from the Unit Converter.
        Specified by:
        processQuantity in interface MicroPropsGenerator
        Parameters:
        quantity - The quantity for consideration and optional mutation.
        Returns:
        A MicroProps instance resolved for the quantity.