Class SiPrefixSelector
- java.lang.Object
-
- com.pervasivecode.utils.measure.impl.SiPrefixSelector
-
- All Implemented Interfaces:
QuantityPrefixSelector
public class SiPrefixSelector extends Object implements QuantityPrefixSelector
Instances select an appropriate SI prefix for a givenQuantity
and return the sameQuantity
transformed to use that prefix.Examples: given 10,000 meters, return 10 kilometers. Given 1,000,000 joules, return 1 megajoule.
-
-
Constructor Summary
Constructors Constructor Description SiPrefixSelector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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.
-
-
-
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 interfaceQuantityPrefixSelector
- 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.
-
-