Package com.irurueta.units
Enum Class WeightUnit
- All Implemented Interfaces:
Serializable,Comparable<WeightUnit>,Constable
Enumerator containing recognized typical weight units.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionGram weight unit.Kilogram weight unit.Metric mega tonne weight unit.Microgram weight unit.Milligram weight unit.Nanogram weight unit.Ounce weight unit.Picogram weight unit.Pound weight unit.Metric tonne weight unit.UK ton weight unit.US ton weight unit. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic WeightUnit[]Gets all supported imperial weight units.static WeightUnit[]Gets all supported metric weight units.static UnitSystemgetUnitSystem(WeightUnit unit) Returns unit system for provided weight unit.static booleanisImperial(WeightUnit unit) Indicates whether provided unit belongs to the imperial unit system.static booleanisMetric(WeightUnit unit) Indicates whether provided unit belongs to the metric unit systemstatic WeightUnitReturns 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
-
PICOGRAM
Picogram weight unit. -
NANOGRAM
Nanogram weight unit. -
MICROGRAM
Microgram weight unit. -
MILLIGRAM
Milligram weight unit. -
GRAM
Gram weight unit. -
KILOGRAM
Kilogram weight unit. -
TONNE
Metric tonne weight unit. -
MEGATONNE
Metric mega tonne weight unit. -
US_TON
US ton weight unit. -
UK_TON
UK ton weight unit. -
POUND
Pound weight unit. -
OUNCE
Ounce weight unit.
-
-
Constructor Details
-
WeightUnit
private WeightUnit()
-
-
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
-
getUnitSystem
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
Gets all supported metric weight units.- Returns:
- all supported metric weight units.
-
getImperialUnits
Gets all supported imperial weight units.- Returns:
- all supported imperial weight units.
-
isMetric
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
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.
-