Interface TypedUnit.UnitSelector<U extends TypedUnit<U>>

    • Method Detail

      • getPreferredUnit

        U getPreferredUnit​(ITypedQuantity<U> quantity,
                           double minNumericalValue,
                           double maxNumericalValue)
      • getLargestExactUnit

        U getLargestExactUnit​(ITypedQuantity<U> quantity)
        Get the largest unit, if any, in which this quantity can be expressed exactly, typically with an integer. If the quantity has zero magnitude ( IQuantity.doubleValue() == 0.0), quantity.getUnit() will be returned. Thus, if you want to find out a maximum common unit for a set of quantities (not recommended), only use the non-zero quantities.

        Note that this may be a fairly expensive operation, and isn't intended to be used excessively. The only valid use case is for guessing the original unit in which a quantity was expressed, after it has been stored or transmitted using a legacy mechanism with a fixed unit.

        Returns:
        a unit or null