Package org.ka2ddo.util
Enum Class TemperatureUnit
- All Implemented Interfaces:
Serializable
,Comparable<TemperatureUnit>
,Constable
,UnitEnum<TemperatureUnit>
This enumeration declares units (with conversion factors) for measuring temperatures.
The default internal temperature units for APRS are degrees Fahrenheit, because that is
what is specified by the message protocols.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
from
(TemperatureUnit other) Get the multiplicative conversion factor to convert a value from the specified units to this unit.final 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.final float
toFahrenheit
(float temp) Convert the specified temperature from this unit to Fahrenheit.final String
Get the string to use when displaying values of this unit.static TemperatureUnit
Returns the enum constant of this class with the specified name.static TemperatureUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
F
Temperature in degrees Fahrenheit. -
C
Temperature in degrees Celsius. -
K
Temperature in degrees Kelvin.
-
-
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
-
toFahrenheit
public final float toFahrenheit(float temp) Convert the specified temperature from this unit to Fahrenheit.- Parameters:
temp
- temperature in the units of this TemperatureUnit- Returns:
- temperature in degrees Fahrenheit
-
fromFahrenheit
public final float fromFahrenheit(float tempF) Convert the specified temperature from this unit to Fahrenheit.- Parameters:
tempF
- temperature in degrees Fahrenheit- Returns:
- temperature in the units of this TemperatureUnit
-
unitString
Get the string to use when displaying values of this unit.- Returns:
- suffix display String
-
from
Get the multiplicative conversion factor to convert a value from the specified units to this unit.- Specified by:
from
in interfaceUnitEnum<TemperatureUnit>
- Parameters:
other
- another TemperatureUnit representing the existing units of a value- Returns:
- the conversion factor to change a value into this unit
-
getOffset
Get the additive offset to convert a value from the specified unit to this unit.- Specified by:
getOffset
in interfaceUnitEnum<TemperatureUnit>
- Parameters:
other
- another TemperatureUnit representing the existing units of a value- Returns:
- the offset (after multiplying by the from() factor) to add to get the value in this unit
-