- All Implemented Interfaces:
Serializable,Comparable<Temperature>,Constable,Dimension
@ClassVersion(sourceVersion="$Id: Temperature.java 1072 2023-09-30 20:44:38Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public enum Temperature
extends Enum<Temperature>
implements Dimension
The various instances of temperature …
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Temperature.java 1072 2023-09-30 20:44:38Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.Temperature"
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final UnaryOperator<BigDecimal> The conversion for the given value from Kelvin to this unit.private final intThe default precision.private final UnaryOperator<BigDecimal> The conversion for the given value from this unit to Kelvin.private final StringThe unit string.Fields inherited from interface org.tquadrat.foundation.value.api.Dimension
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTemperature(UnaryOperator<BigDecimal> fromKelvin, UnaryOperator<BigDecimal> toKelvin, String unitSymbol) Creates a newTemperaturinstance, with a default precision of zero mantissa digits.privateTemperature(UnaryOperator<BigDecimal> fromKelvin, UnaryOperator<BigDecimal> toKelvin, String unitSymbol, int precision) Creates a newTemperaturinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal TemperaturebaseUnit()Returns the base unit.static final TemperatureReturns theTemperatureinstance for the given unit symbol.final UnaryOperator<BigDecimal> fromBase()Returns the conversion that is used to convert a value from the base unit to this unit.final intReturns the default precision for this unit that is used when the respective value is converted to a String.final UnaryOperator<BigDecimal> toBase()Returns the conversion that is used to convert a value from this unit to the base unit.final StringtoString()final StringReturns the unit symbol for the dimension as a single line string.static TemperatureReturns the enum constant of this class with the specified name.static Temperature[]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, valueOfMethods inherited from interface org.tquadrat.foundation.value.api.Dimension
equals, name, unitSymbolForPrinting
-
Enum Constant Details
-
KELVIN
Kelvin. -
CELSIUS
Celsius. -
FAHRENHEIT
Fahrenheit -
RANKINE
Rankine. -
DELISLE
Delisle. -
REAUMUR
Réaumur. -
NEWTON
Newton.
Yes, there is really a unit "Newton" for temperatures! It was introduced by Isaac Newton at the beginning of the 18th century, but was not well established.
-
RØMER
Rømer.
-
-
Field Details
-
m_FromKelvin
The conversion for the given value from Kelvin to this unit. -
m_ToKelvin
The conversion for the given value from this unit to Kelvin. -
m_Precision
The default precision. -
m_UnitSymbol
The unit string.
-
-
Constructor Details
-
Temperature
private Temperature(UnaryOperator<BigDecimal> fromKelvin, UnaryOperator<BigDecimal> toKelvin, String unitSymbol) Creates a newTemperaturinstance, with a default precision of zero mantissa digits.- Parameters:
fromKelvin- The conversion from Kelvin.toKelvin- The conversion to Kelvin.unitSymbol- The unit symbol String.
-
Temperature
private Temperature(UnaryOperator<BigDecimal> fromKelvin, UnaryOperator<BigDecimal> toKelvin, String unitSymbol, int precision) Creates a newTemperaturinstance.- Parameters:
fromKelvin- The conversion from Kelvin.toKelvin- The conversion to Kelvin.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.
-
fromBase
Returns the conversion that is used to convert a value from the base unit to this unit.
-
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.
-
toBase
Returns the conversion that is used to convert a value from this unit to the base unit.
-
toString
- Specified by:
toStringin interfaceDimension- Overrides:
toStringin classEnum<Temperature>
-
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.
-
forUnit
Returns theTemperatureinstance for the given unit symbol.- Parameters:
unitSymbol- The unit symbol.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
