Package com.iizix
Enum TemperatureUnit
- java.lang.Object
- java.lang.Enum<TemperatureUnit>
- com.iizix.TemperatureUnit
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<TemperatureUnit>
public enum TemperatureUnit extends java.lang.Enum<TemperatureUnit>
Enum for temperature types.
Enum Constant Summary
Enum Constants Enum Constant Description CELCIUS
Celcius formatted as "°C".FAHRENHEIT
Fahrenheit formatted as "°F".KELVIN
Kelvin "°K".RANKINE
Rankine "°R".
Field Summary
Fields Modifier and Type Field Description java.lang.String
suffix
Suffix for temperature value.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract double
toCelcius(double temperature)
Converts the temperature of the current temperature unit to Celcius.abstract float
toCelcius(float temperature)
Converts the temperature of the current temperature unit to Celcius.abstract double
toFahrenheit(double temperature)
Converts the temperature of the current temperature unit to Fahrenheit.abstract float
toFahrenheit(float temperature)
Converts the temperature of the current temperature unit to Fahrenheit.abstract double
toKelvin(double temperature)
Converts the temperature of the current temperature unit to Kelvin.abstract float
toKelvin(float temperature)
Converts the temperature of the current temperature unit to Kelvin.abstract double
toRankine(double temperature)
Converts the temperature of the current temperature unit to Rankine.abstract float
toRankine(float temperature)
Converts the temperature of the current temperature unit to Rankine.double
toType(double temperature, TemperatureUnit unit)
Converts the temperature of the current temperature unit to the requested temperature unit type.float
toType(float temperature, TemperatureUnit unit)
Converts the temperature of the current temperature unit to the requested temperature unit type.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.
Enum Constant Detail
CELCIUS
public static final TemperatureUnit CELCIUS
Celcius formatted as "°C".
FAHRENHEIT
public static final TemperatureUnit FAHRENHEIT
Fahrenheit formatted as "°F".
KELVIN
public static final TemperatureUnit KELVIN
Kelvin "°K".
RANKINE
public static final TemperatureUnit RANKINE
Rankine "°R".
Method Detail
values
public static TemperatureUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TemperatureUnit c : TemperatureUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
valueOf
public static TemperatureUnit valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
toCelcius
public abstract double toCelcius(double temperature)
Converts the temperature of the current temperature unit to Celcius.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Celcius.
toCelcius
public abstract float toCelcius(float temperature)
Converts the temperature of the current temperature unit to Celcius.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Celcius.
toFahrenheit
public abstract double toFahrenheit(double temperature)
Converts the temperature of the current temperature unit to Fahrenheit.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Fahrenheit.
toFahrenheit
public abstract float toFahrenheit(float temperature)
Converts the temperature of the current temperature unit to Fahrenheit.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Fahrenheit.
toKelvin
public abstract double toKelvin(double temperature)
Converts the temperature of the current temperature unit to Kelvin.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Kelvin.
toKelvin
public abstract float toKelvin(float temperature)
Converts the temperature of the current temperature unit to Kelvin.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Kelvin.
toRankine
public abstract double toRankine(double temperature)
Converts the temperature of the current temperature unit to Rankine.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Rankine.
toRankine
public abstract float toRankine(float temperature)
Converts the temperature of the current temperature unit to Rankine.- Parameters:
temperature
- The temperature.- Returns:
- The temperature in Rankine.
toType
public double toType(double temperature, TemperatureUnit unit)
Converts the temperature of the current temperature unit to the requested temperature unit type.- Parameters:
temperature
- The temperature.unit
- Requested conversion temperature unit type.- Returns:
- The temperature in the requested unit type.
- Throws:
java.lang.NullPointerException
- Ifunit
isnull
.
toType
public float toType(float temperature, TemperatureUnit unit)
Converts the temperature of the current temperature unit to the requested temperature unit type.- Parameters:
temperature
- The temperature.unit
- Requested conversion temperature unit type.- Returns:
- The temperature in the requested unit type.
- Throws:
java.lang.NullPointerException
- Ifunit
isnull
.