Enum Class Mass
- All Implemented Interfaces:
Serializable, Comparable<Mass>, Constable, Dimension, DimensionWithLinearConversion
@ClassVersion(sourceVersion="$Id: Mass.java 1195 2026-04-15 21:33:40Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public enum Mass
extends Enum<Mass>
implements DimensionWithLinearConversion
The various instances of masses and weights (although this is not really
the same, from a physical or scientific point of view ...).
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Mass.java 1195 2026-04-15 21:33:40Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.Mass"
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA metric carat; this is defined as 0.2 g; although no unit sign is officially defined, the use of "ct" is widely accepted.A dram (Avoirdupois), a 1/16 of an ounce.The mass of our planet Earth.An English grain.A gram.A kilogram.A milligram.An ounce (Avoirdupois), a 1/16 of a pound.An imperial pound (Avoirdupois), 7000 grain.A short ton (2000 pound avoirdupois).The (estimated) mass of our sun.A stone; although abandoned since 1985, it will still be used in some Commonwealth countries to determine the body weight.A metric ton.A troy ounce (same as Apothecaries Ounce, as used for precious metals). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigDecimalThe factor.private final intThe default precision.private final StringThe unit string.Fields inherited from interface DimensionWithLinearConversion
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMass(BigDecimal factor, String unitSymbol) Creates a newMassinstance with a default precision of zero mantissa digits.privateMass(BigDecimal factor, String unitSymbol, int precision) Creates a newMassinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal MassbaseUnit()final BigDecimalfactor()static final MassReturns theWeightinstance for the given unit.final intfinal Stringstatic MassReturns the enum constant of this class with the specified name.static Mass[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface Dimension
equals, name, toString, unitSymbolForPrintingMethods inherited from interface DimensionWithLinearConversion
fromBase, toBase
-
Enum Constant Details
-
MILLIGRAM
-
GRAIN
-
CARAT
-
GRAM
-
DRAM
-
OUNCE
-
TROY_OUNCE
A troy ounce (same as Apothecaries Ounce, as used for precious metals). -
POUND
-
KILOGRAM
-
STONE
-
SHORT_TON
-
TON
-
SOLAR_MASS
-
EARTH_MASS
-
-
Field Details
-
m_Factor
The factor. -
m_Precision
The default precision. -
m_UnitSymbol
The unit string.
-
-
Constructor Details
-
Mass
Creates a newMassinstance with a default precision of zero mantissa digits.- Parameters:
factor- The factor.unitSymbol- The unit string.
-
Mass
Creates a newMassinstance.- Parameters:
factor- The factor.unitSymbol- The unit string.precision- The default precision.
-
-
Method Details
-
values
-
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
-
baseUnit
-
factor
- Specified by:
factorin interfaceDimensionWithLinearConversion
-
forUnit
Returns theWeightinstance for the given unit.- Parameters:
unitSymbol- The unit symbol.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
getPrecision
- Specified by:
getPrecisionin interfaceDimension
-
unitSymbol
- Specified by:
unitSymbolin interfaceDimension
-
