Enum Class TemperatureUnit

java.lang.Object
java.lang.Enum<TemperatureUnit>
org.ka2ddo.util.TemperatureUnit
All Implemented Interfaces:
Serializable, Comparable<TemperatureUnit>, Constable, UnitEnum<TemperatureUnit>

public enum TemperatureUnit extends Enum<TemperatureUnit> implements 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
  • Enum Constant Details

    • F

      public static final TemperatureUnit F
      Temperature in degrees Fahrenheit.
    • C

      public static final TemperatureUnit C
      Temperature in degrees Celsius.
    • K

      public static final TemperatureUnit K
      Temperature in degrees Kelvin.
  • Method Details

    • values

      public static TemperatureUnit[] 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

      public static TemperatureUnit valueOf(String name)
      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 name
      NullPointerException - 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

      public final String unitString()
      Get the string to use when displaying values of this unit.
      Returns:
      suffix display String
    • from

      public float from(TemperatureUnit other)
      Get the multiplicative conversion factor to convert a value from the specified units to this unit.
      Specified by:
      from in interface UnitEnum<TemperatureUnit>
      Parameters:
      other - another TemperatureUnit representing the existing units of a value
      Returns:
      the conversion factor to change a value into this unit
    • getOffset

      public float getOffset(TemperatureUnit other)
      Get the additive offset to convert a value from the specified unit to this unit.
      Specified by:
      getOffset in interface UnitEnum<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