public enum TemperatureUnit extends java.lang.Enum<TemperatureUnit> implements UnitEnum<TemperatureUnit>
Enum Constant and Description |
---|
C
Temperature in degrees Celsius.
|
F
Temperature in degrees Fahrenheit.
|
K
Temperature in degrees Kelvin.
|
Modifier and Type | Method and Description |
---|---|
float |
from(TemperatureUnit other)
Get the multiplicative conversion factor to convert a value from the specified
units to this unit.
|
float |
fromFahrenheit(float tempF)
Convert the specified temperature from this unit to Fahrenheit.
|
float |
getOffset(TemperatureUnit other)
Get the additive offset to convert a value from the specified unit to this unit.
|
float |
toFahrenheit(float temp)
Convert the specified temperature from this unit to Fahrenheit.
|
java.lang.String |
unitString()
Get the string to use when displaying values of this unit.
|
static TemperatureUnit |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static TemperatureUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TemperatureUnit F
public static final TemperatureUnit C
public static final TemperatureUnit K
public static TemperatureUnit[] values()
for (TemperatureUnit c : TemperatureUnit.values()) System.out.println(c);
public static TemperatureUnit valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic final float toFahrenheit(float temp)
temp
- temperature in the units of this TemperatureUnitpublic final float fromFahrenheit(float tempF)
tempF
- temperature in degrees Fahrenheitpublic final java.lang.String unitString()
public float from(TemperatureUnit other)
from
in interface UnitEnum<TemperatureUnit>
other
- another TemperatureUnit representing the existing units of a valuepublic float getOffset(TemperatureUnit other)
getOffset
in interface UnitEnum<TemperatureUnit>
other
- another TemperatureUnit representing the existing units of a value