Package org.goplanit.utils.unit
Interface Unit
-
- All Known Implementing Classes:
DistanceUnit,GroupUnit,NoneUnit,SimpleUnit,SrsUnit,TimeUnit,VehiclesUnit
public interface UnitLightweight Unit interface to define units and allow for conversions between them- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static TimeUnitHOURpredefined HOUR TimeUnitstatic DistanceUnitKMpredefined KM DistanceUnitstatic UnitKM_HOURpredefined KM/HOUR Unitstatic DistanceUnitMETERpredefined METER DistanceUnitstatic UnitMETER_SECONDpredefined METER/SECOND Unitstatic TimeUnitMINUTEpredefined MINUTE TimeUnitstatic UnitNONEstatic VehiclesUnitPCUpredefined PCU VehiclesUnitstatic UnitPCU_HOURpredefined PCU/HOUR Unitstatic UnitPCU_KMpredefined PCU/KM Unitstatic TimeUnitSECONDpredefined SECOND TimeUnitstatic UnitSRSpredefined SRS SRSUnitstatic VehiclesUnitVEHpredefined VEHICLE VehiclesUnitstatic UnitVEH_HOURpredefined VEH/HOUR Unitstatic UnitVEH_KMpredefined VEH/KM Unit
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanConvertTo(Unit to)Verify if unit can be converted to the desired unitdoubleconvertTo(Unit to, double value)Convert one unit to the other for a given valuebooleanisCombinedUnit()Is the unit a single or combined unitstatic SimpleUnitof(UnitType type)Create unit based on given typestatic GroupUnitof(UnitType[] numeratorUnits, UnitType[] denominatorUnits)Create unit based on given types
-
-
-
Field Detail
-
NONE
static final Unit NONE
-
HOUR
static final TimeUnit HOUR
predefined HOUR TimeUnit
-
MINUTE
static final TimeUnit MINUTE
predefined MINUTE TimeUnit
-
SECOND
static final TimeUnit SECOND
predefined SECOND TimeUnit
-
KM
static final DistanceUnit KM
predefined KM DistanceUnit
-
METER
static final DistanceUnit METER
predefined METER DistanceUnit
-
PCU
static final VehiclesUnit PCU
predefined PCU VehiclesUnit
-
VEH
static final VehiclesUnit VEH
predefined VEHICLE VehiclesUnit
-
SRS
static final Unit SRS
predefined SRS SRSUnit
-
KM_HOUR
static final Unit KM_HOUR
predefined KM/HOUR Unit
-
METER_SECOND
static final Unit METER_SECOND
predefined METER/SECOND Unit
-
PCU_HOUR
static final Unit PCU_HOUR
predefined PCU/HOUR Unit
-
PCU_KM
static final Unit PCU_KM
predefined PCU/KM Unit
-
VEH_HOUR
static final Unit VEH_HOUR
predefined VEH/HOUR Unit
-
VEH_KM
static final Unit VEH_KM
predefined VEH/KM Unit
-
-
Method Detail
-
isCombinedUnit
boolean isCombinedUnit()
Is the unit a single or combined unit- Returns:
- false when single, true when combined
-
convertTo
double convertTo(Unit to, double value) throws PlanItException
Convert one unit to the other for a given value- Parameters:
to- to unitvalue- value to convert- Returns:
- converted value
- Throws:
PlanItException- thrown if not possible to perform conversion
-
canConvertTo
boolean canConvertTo(Unit to)
Verify if unit can be converted to the desired unit- Parameters:
to- to unit- Returns:
- true when compatible, false otherwise
-
of
static SimpleUnit of(UnitType type)
Create unit based on given type- Parameters:
type- to use- Returns:
- unit created
-
-