java.lang.Object
de.turnertech.measures.Unit
A Unit is a single instance of a Measurement, such as a Metre or a Degree Celsius.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Unitcmstatic final Unitdegstatic final Unit°Cstatic final Unit°Fstatic final Unitft_istatic final Unitgstatic final Unitin_istatic final UnitKstatic final Unitkmstatic final Unitmstatic final Unitmi_istatic final Unitnmi_istatic final Unitlb_avstatic final Unitradstatic final Unitsstatic final Unityd_i -
Method Summary
Modifier and TypeMethodDescriptionconvertFromBaseUnit(double quantity) Converts a supplied quantity of this Units base unit to a quantity of itself.convertToBaseUnit(double quantity) Converts a supplied quantity of this Unit to a quantity of its base unit.createMeasure(double quantity) Helper function for creating measures with a Unit.Gets the common base unit for the family of units to which this Unit belongs.
-
Field Details
-
KELVIN
K -
DEGREES_CELSIUS
°C -
DEGREES_FAHRENHEIT
°F -
METRE
m -
CENTIMETRE
cm -
INCH
in_i -
FOOT
ft_i -
YARD
yd_i -
MILE
mi_i -
KILOMETRE
km -
NAUTICAL_MILE
nmi_i -
SECOND
s -
GRAM
g -
POUND
lb_av -
RADIAN
rad -
DEGREE
deg
-
-
Method Details
-
createMeasure
Helper function for creating measures with a Unit.- Parameters:
quantity- the quantity of this unit which should be in the Measure.- Returns:
- a new Measure instance.
-
getBaseUnit
Gets the common base unit for the family of units to which this Unit belongs. For example, Metres are the base Unit for all distance Units. Even Feet, Inches and Nautical Miles will share the same base unit of a Metre.- Returns:
- the base unit for this Unit.
-
convertToBaseUnit
Converts a supplied quantity of this Unit to a quantity of its base unit. For example supplying a quantity of 1 to this function on an instance ofKILOMETREwill return 1000 (metres).- Parameters:
quantity- of this Unit to convert to the base unit.- Returns:
- the quantity of the Base Unit which the supplied quantity represents.
-
convertFromBaseUnit
Converts a supplied quantity of this Units base unit to a quantity of itself.- Parameters:
quantity- of this Unit base unit to convert to this unit.- Returns:
- a measure with this Unit.
-