- All Implemented Interfaces:
Serializable,Comparable<Volume>,Constable,Dimension,DimensionWithLinearConversion
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Volume.java 1073 2023-10-01 11:08:51Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.Volume"
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA barrel as used for mineral oil.A bucket ("Eimer" in German).A centiliter.A cubic centimeter.A cubic decimeter.A cubic foot.A cubic inch.A cubic kilometer.A cubic meter.A cubic mile.A cubic millimeter.A cubic yard.A deciliter.A "Festmeter"; this is used (in Germany) to specify an amount of wood.An imperial fluid ounce.An imperial gallon.A hekto liter.An imperial barrel.A liter.A micro liter.A milliliter.A pint liquid imperial.A ton as used by Traveller® to specify the volume of a starship or other space going vessels or orbital installations.A US (liquid) gallon. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigDecimalThe factor.private final intThe default precision.private final StringThe unit string.Fields inherited from interface org.tquadrat.foundation.value.api.DimensionWithLinearConversion
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateVolume(BigDecimal factor, String unitSymbol) Creates a newVolumeinstance, with a default precision of zero mantissa digits.privateVolume(BigDecimal factor, String unitSymbol, int precision) Creates a newVolumeinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal VolumebaseUnit()Returns the base unit.final BigDecimalfactor()Returns the factor that is used to convert a value from this unit to the base unit.static final VolumeReturns theVolumeinstance for the given unit symbol.final intReturns the default precision for this unit that is used when the respective value is converted to a String.final StringReturns the unit symbol for the dimension as a single line string.static VolumeReturns the enum constant of this class with the specified name.static Volume[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface org.tquadrat.foundation.value.api.Dimension
equals, name, toString, unitSymbolForPrintingMethods inherited from interface org.tquadrat.foundation.value.api.DimensionWithLinearConversion
fromBase, toBase
-
Enum Constant Details
-
CUBIC_MILLIMETER
A cubic millimeter. -
MICRO_LITER
A micro liter. -
CUBIC_CENTIMETER
A cubic centimeter. -
MILLI_LITER
A milliliter. -
CENTI_LITER
A centiliter. -
CUBIC_INCH
A cubic inch. -
FLUID_OUNCE_IMPERIAL
An imperial fluid ounce. -
DECI_LITER
A deciliter. -
PINT_LIQUID_IMPERIAL
A pint liquid imperial. -
CUBIC_DECIMETER
A cubic decimeter. -
LITER
A liter. -
BUCKET
A bucket ("Eimer" in German). Obviously, this is not an official unit for a volume, but it is used quit often on a colloquial basis in Germany and other German-speaking countries to describe the amount of 10 liters. -
US_GALLON
A US (liquid) gallon. -
GALLON
An imperial gallon. -
CUBIC_FOOT
A cubic foot. -
HEKTO_LITER
A hekto liter. -
BARREL_OIL
A barrel as used for mineral oil. -
IMPERIAL_BARREL
An imperial barrel. -
CUBIC_YARD
A cubic yard. -
CUBIC_METER
A cubic meter. -
FESTMETER
A "Festmeter"; this is used (in Germany) to specify an amount of wood. -
TON
A ton as used by Traveller® to specify the volume of a starship or other space going vessels or orbital installations. It is defined as the volume of one metric ton or 1000 kg of liquid hydrogen (H2) with a specific density of 71 kg/m3.
The Traveller® literature also uses a value of 13.5 m3, based on the dimensions used with ship floor plans: a square on such a plan has a side length of 1.5 m and the room height is taken as 3 m, with each square is the equivalent of half a ton (or 6.75 m3). For mapping purposes this is a valid approximation.
-
CUBIC_KILO_METER
A cubic kilometer. -
CUBIC_MILE
A cubic mile.
-
-
Field Details
-
m_Factor
The factor. -
m_Precision
The default precision. -
m_UnitSymbol
The unit string.
-
-
Constructor Details
-
Volume
Creates a newVolumeinstance, with a default precision of zero mantissa digits.- Parameters:
factor- The factor.unitSymbol- The unit symbol String.
-
Volume
Creates a newVolumeinstance.- Parameters:
factor- The factor.unitSymbol- The unit symbol String.precision- The default precision.
-
-
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
-
baseUnit
Returns the base unit.
E.g. for length, the base unit would be Meter (m), for mass, it is Kilogram (kg), and so on.
-
factor
Returns the factor that is used to convert a value from this unit to the base unit.
For length, if you have to convert a Centimeter value to Meter, you will divide that by 100 or multiply it with a factor of 0.01.
For the base unit, the factor is 1.0.
- Specified by:
factorin interfaceDimensionWithLinearConversion- Returns:
- The factor.
- See Also:
-
forUnit
Returns theVolumeinstance for the given unit symbol.- Parameters:
unitSymbol- The unit symbol.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
getPrecision
Returns the default precision for this unit that is used when the respective value is converted to a String.- Specified by:
getPrecisionin interfaceDimension- Returns:
- The mantissa length for a value with this unit.
-
unitSymbol
Returns the unit symbol for the dimension as a single line string.
For a length, this would be "m", for a speed "km/h", and for an acceleration, it could be "m/(s^2)".
- Specified by:
unitSymbolin interfaceDimension- Returns:
- The unit.
-
