Package org.ka2ddo.util
Enum Class WeightUnit
- All Implemented Interfaces:
Serializable
,Comparable<WeightUnit>
,Constable
,UnitEnum<WeightUnit>
This enumeration declares units (with conversion factors) for measuring weights (including
units of mass that are commonly used for weight in one standard Earth gravity).
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal float
from
(WeightUnit other) Get the multiplicative conversion factor to convert a weight from the specified units to this unit.Get short standard abbreviations for this WeightUnit.static WeightUnit[]
Get the units of weight that are "heavy" (enough for a motorized vehicle).float
getOffset
(WeightUnit other) Get the additive offset to convert a value from the specified unit to this unit.static WeightUnit
getUnitForName
(String name) Get the enumeration corresponding to the specified weight unit String name.static WeightUnit
Returns the enum constant of this class with the specified name.static WeightUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
POUND
Weights in pounds. -
KILOGRAM
Weights in kilograms. -
CWT
Weights in hundreds of pounds-mass. -
PERSON
Weights in number of average-sized adult human beings. -
TON
Weights in short tons, -
METRIC_TON
Weights in metric tons. -
LONG_TON
Weights in long tons.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
from
Get the multiplicative conversion factor to convert a weight from the specified units to this unit.- Specified by:
from
in interfaceUnitEnum<WeightUnit>
- Parameters:
other
- another WeightUnit representing the existing units of a Weight value- Returns:
- the conversion factor to change a Weight value into this unit
-
getOffset
Get the additive offset to convert a value from the specified unit to this unit.- Specified by:
getOffset
in interfaceUnitEnum<WeightUnit>
- Parameters:
other
- another WeightUnit representing the existing units of a value- Returns:
- the offset (after multiplying by the from() factor) to add to get the value in this unit
-
getAbbreviation
Get short standard abbreviations for this WeightUnit.- Returns:
- abbreviations string
-
getUnitForName
Get the enumeration corresponding to the specified weight unit String name.- Parameters:
name
- String to convert inti a WeightUnit- Returns:
- WeightUnit corresponding to the String, or null if no matching WeightUnit
-
getHeavyWeightUnits
Get the units of weight that are "heavy" (enough for a motorized vehicle).- Returns:
- array of WeightUnits
-