Package org.goplanit.utils.unit
Class GroupUnit
- java.lang.Object
-
- org.goplanit.utils.unit.GroupUnit
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupUnit(GroupUnit other, SimpleUnit... denominatorUnits)
Constructorprotected
GroupUnit(SimpleUnit... numeratorUnits)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvertTo(Unit to)
Verify if unit can be converted to the desired unitdouble
convertTo(Unit to, double value)
Convert one unit to the other for a given valueboolean
equals(Object o)
protected List<SimpleUnit>
getDenominatorUnitTypes()
All registered units in the denominatorprotected List<SimpleUnit>
getNumeratorUnitTypes()
All registered units in the numeratorboolean
isCombinedUnit()
Is the unit a single or combined unitGroupUnit
per(SimpleUnit... denominatorUnits)
Factory method to create a new groupUnit with this unit's numerator and additionally added denominator units, e.g., KM per HourString
toString()
-
-
-
Constructor Detail
-
GroupUnit
protected GroupUnit(SimpleUnit... numeratorUnits)
Constructor- Parameters:
numeratorUnits
- to use
-
GroupUnit
protected GroupUnit(GroupUnit other, SimpleUnit... denominatorUnits)
Constructor- Parameters:
other
- to copy numerator units fromdenominatorUnits
- to use
-
-
Method Detail
-
per
public GroupUnit per(SimpleUnit... denominatorUnits)
Factory method to create a new groupUnit with this unit's numerator and additionally added denominator units, e.g., KM per Hour- Parameters:
denominatorUnits
- to use- Returns:
- newly combined group unit
-
isCombinedUnit
public boolean isCombinedUnit()
Is the unit a single or combined unit- Specified by:
isCombinedUnit
in interfaceUnit
- Returns:
- false when single, true when combined
-
getNumeratorUnitTypes
protected List<SimpleUnit> getNumeratorUnitTypes()
All registered units in the numerator- Returns:
- numerator units
-
getDenominatorUnitTypes
protected List<SimpleUnit> getDenominatorUnitTypes()
All registered units in the denominator- Returns:
- numerator units
-
convertTo
public double convertTo(Unit to, double value)
Convert one unit to the other for a given value
-
canConvertTo
public boolean canConvertTo(Unit to)
Verify if unit can be converted to the desired unit- Specified by:
canConvertTo
in interfaceUnit
- Parameters:
to
- to unit- Returns:
- true when compatible, false otherwise
-
-