Class UnitFactors
- java.lang.Object
-
- com.squarespace.cldrengine.units.conversion.UnitFactors
-
public class UnitFactors extends java.lang.Object
Build a graph of conversion factors between units. Sets of conversion factors are closed, e.g. any factor must be convertable into any other unit in the set. Their must be a connected path of length 1 or greater between any two units. Gaps in the graph represent conversion factors that are unknown at the time of graph construction. These are incrementally filled in on demand by finding the shortest and lowest-cost conversion path between two units with no direct conversion factor. The path is transformed into a direct conversion factor by multiplying all factors along the path. Finally the new factor is added to the graph.
-
-
Constructor Summary
Constructors Constructor Description UnitFactors(java.util.List<FactorDef> factors)
UnitFactors(java.util.List<FactorDef> factors, boolean memoize)
Build a unit converter graph using the given factors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnitConversion
get(UnitType src, UnitType dst)
Return the factor that converts units of 'src' into 'dst'.java.lang.String
toString()
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
get
public UnitConversion get(UnitType src, UnitType dst)
Return the factor that converts units of 'src' into 'dst'.
-
-