Class SiPrefixSelector

  • All Implemented Interfaces:
    QuantityPrefixSelector

    public class SiPrefixSelector
    extends Object
    implements QuantityPrefixSelector
    Instances select an appropriate SI prefix for a given Quantity and return the same Quantity transformed to use that prefix.

    Examples: given 10,000 meters, return 10 kilometers. Given 1,000,000 joules, return 1 megajoule.

    • Constructor Detail

      • SiPrefixSelector

        public SiPrefixSelector()
    • Method Detail

      • selectBestPrefix

        public <Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> selectBestPrefix​(javax.measure.Quantity<Q> measure,
                                                                                                javax.measure.Unit<Q> formatUnit)
        Apply an appropriate prefix from the SI set of prefixes for a given measurement.
        Specified by:
        selectBestPrefix in interface QuantityPrefixSelector
        Type Parameters:
        Q - The kind of value represented by the measure. Example: Mass
        Parameters:
        measure - A value to scale with a prefix.
        formatUnit - The base "ones" unit of the provided measure.
        Returns:
        The measurement, transformed with an appropriate prefix from the SI system.