Enum Class WeightUnit

java.lang.Object
java.lang.Enum<WeightUnit>
com.irurueta.units.WeightUnit
All Implemented Interfaces:
Serializable, Comparable<WeightUnit>, Constable

public enum WeightUnit extends Enum<WeightUnit>
Enumerator containing recognized typical weight units.
  • Enum Constant Details

    • PICOGRAM

      public static final WeightUnit PICOGRAM
      Picogram weight unit.
    • NANOGRAM

      public static final WeightUnit NANOGRAM
      Nanogram weight unit.
    • MICROGRAM

      public static final WeightUnit MICROGRAM
      Microgram weight unit.
    • MILLIGRAM

      public static final WeightUnit MILLIGRAM
      Milligram weight unit.
    • GRAM

      public static final WeightUnit GRAM
      Gram weight unit.
    • KILOGRAM

      public static final WeightUnit KILOGRAM
      Kilogram weight unit.
    • TONNE

      public static final WeightUnit TONNE
      Metric tonne weight unit.
    • MEGATONNE

      public static final WeightUnit MEGATONNE
      Metric mega tonne weight unit.
    • US_TON

      public static final WeightUnit US_TON
      US ton weight unit.
    • UK_TON

      public static final WeightUnit UK_TON
      UK ton weight unit.
    • POUND

      public static final WeightUnit POUND
      Pound weight unit.
    • OUNCE

      public static final WeightUnit OUNCE
      Ounce weight unit.
  • Constructor Details

    • WeightUnit

      private WeightUnit()
  • 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
    • getUnitSystem

      public static UnitSystem getUnitSystem(WeightUnit unit)
      Returns unit system for provided weight unit.
      Parameters:
      unit - weight unit to be checked.
      Returns:
      unit system (metric or imperial).
      Throws:
      IllegalArgumentException - if unit is null or not supported.
    • getMetricUnits

      public static WeightUnit[] getMetricUnits()
      Gets all supported metric weight units.
      Returns:
      all supported metric weight units.
    • getImperialUnits

      public static WeightUnit[] getImperialUnits()
      Gets all supported imperial weight units.
      Returns:
      all supported imperial weight units.
    • isMetric

      public static boolean isMetric(WeightUnit unit)
      Indicates whether provided unit belongs to the metric unit system
      Parameters:
      unit - weight unit to be checked.
      Returns:
      true if unit belongs to metric unit system.
      Throws:
      IllegalArgumentException - if unit is null or not supported.
    • isImperial

      public static boolean isImperial(WeightUnit unit)
      Indicates whether provided unit belongs to the imperial unit system.
      Parameters:
      unit - weight unit to be checked.
      Returns:
      true if unit belongs to imperial unit system.
      Throws:
      IllegalArgumentException - if unit is null or not supported.