Enum Class WeightUnit

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

public enum WeightUnit extends Enum<WeightUnit> implements 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
  • Enum Constant Details

    • POUND

      public static final WeightUnit POUND
      Weights in pounds.
    • KILOGRAM

      public static final WeightUnit KILOGRAM
      Weights in kilograms.
    • CWT

      public static final WeightUnit CWT
      Weights in hundreds of pounds-mass.
    • PERSON

      public static final WeightUnit PERSON
      Weights in number of average-sized adult human beings.
    • TON

      public static final WeightUnit TON
      Weights in short tons,
    • METRIC_TON

      public static final WeightUnit METRIC_TON
      Weights in metric tons.
    • LONG_TON

      public static final WeightUnit LONG_TON
      Weights in long tons.
  • Method Details

    • values

      public static WeightUnit[] 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

      public static WeightUnit valueOf(String name)
      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 name
      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 String getAbbreviation()
      Get short standard abbreviations for this WeightUnit.
      Returns:
      abbreviations string
    • getUnitForName

      public static WeightUnit getUnitForName(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