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 CELCIUSCelcius formatted as "°C".FAHRENHEITFahrenheit formatted as "°F".KELVINKelvin "°K".RANKINERankine "°R".
Field Summary
Fields Modifier and Type Field Description java.lang.StringsuffixSuffix for temperature value.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract doubletoCelcius(double temperature)Converts the temperature of the current temperature unit to Celcius.abstract floattoCelcius(float temperature)Converts the temperature of the current temperature unit to Celcius.abstract doubletoFahrenheit(double temperature)Converts the temperature of the current temperature unit to Fahrenheit.abstract floattoFahrenheit(float temperature)Converts the temperature of the current temperature unit to Fahrenheit.abstract doubletoKelvin(double temperature)Converts the temperature of the current temperature unit to Kelvin.abstract floattoKelvin(float temperature)Converts the temperature of the current temperature unit to Kelvin.abstract doubletoRankine(double temperature)Converts the temperature of the current temperature unit to Rankine.abstract floattoRankine(float temperature)Converts the temperature of the current temperature unit to Rankine.doubletoType(double temperature, TemperatureUnit unit)Converts the temperature of the current temperature unit to the requested temperature unit type.floattoType(float temperature, TemperatureUnit unit)Converts the temperature of the current temperature unit to the requested temperature unit type.static TemperatureUnitvalueOf(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- Ifunitisnull.
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- Ifunitisnull.