org.ka2ddo.util
Enum WeightUnit

java.lang.Object
  extended by java.lang.Enum<WeightUnit>
      extended by org.ka2ddo.util.WeightUnit
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<WeightUnit>, UnitEnum<WeightUnit>

public enum WeightUnit
extends java.lang.Enum<WeightUnit>
implements UnitEnum<WeightUnit>

This enumeration declares units (with conversion factors) for measuring weights (including units of mass that are used for weight in one standard Earth gravity).


Enum Constant Summary
KILOGRAM
          Weights in kilograms.
METRIC_TON
          Weights in metric tons.
POUND
          Weights in pounds.
TON
          Weights in short tons,
 
Method Summary
 float from(WeightUnit other)
          Get the multiplicative conversion factor to convert a weight from the specified units to this unit.
 java.lang.String getAbbreviation()
          Get short standard abbreviation for this WeightUnit.
static WeightUnit[] getHeavyWeightUnits()
          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(java.lang.String name)
          Get the enumeration corresponding to the specified weight unit String name.
static WeightUnit valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static WeightUnit[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

POUND

public static final WeightUnit POUND
Weights in pounds.


KILOGRAM

public static final WeightUnit KILOGRAM
Weights in kilograms.


TON

public static final WeightUnit TON
Weights in short tons,


METRIC_TON

public static final WeightUnit METRIC_TON
Weights in metric tons.

Method Detail

values

public static WeightUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (WeightUnit c : WeightUnit.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static WeightUnit valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

from

public final float from(WeightUnit other)
Get the multiplicative conversion factor to convert a weight from the specified units to this unit.

Specified by:
from in interface UnitEnum<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

public float getOffset(WeightUnit other)
Get the additive offset to convert a value from the specified unit to this unit.

Specified by:
getOffset in interface UnitEnum<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

public java.lang.String getAbbreviation()
Get short standard abbreviation for this WeightUnit.

Returns:
abbreviation string

getUnitForName

public static WeightUnit getUnitForName(java.lang.String name)
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

public static WeightUnit[] getHeavyWeightUnits()
Get the units of weight that are "heavy" (enough for a motorized vehicle).

Returns:
array of WeightUnits