public enum TemperatureUnit extends java.lang.Enum<TemperatureUnit>
| Enum Constant and Description |
|---|
CELSIUS
For the Celsius temperature scale.
|
FAHRENHEIT
For the Fahrenheit temperature scale.
|
| Modifier and Type | Method and Description |
|---|---|
static TemperatureUnit |
fromString(java.lang.String string)
|
java.util.SortedSet<Temperature> |
range(double firstValue,
double lastValue,
double step)
Returns a non-null low-to-high
SortedSet of
Temperature objects, with values running from
firstValue to lastValue (inclusive), and the
specified step between each consecutive temperature. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this enum constant
in the format required to specify a
TemperatureUnit in the
request XML ("Celsius" or "Fahrenheit"). |
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 CELSIUS
public static final TemperatureUnit FAHRENHEIT
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 java.util.SortedSet<Temperature> range(double firstValue, double lastValue, double step)
SortedSet of
Temperature objects, with values running from
firstValue to lastValue (inclusive), and the
specified step between each consecutive temperature.
For example, to get Celsius temperatures between 10°C and 30°C (inclusive), with each temperature being 5°C greater than the last (giving temperatures 10°C, 15°C, 20°C, 25°C, and 30°C):
SortedSet<Temperature> temps = TemperatureUnit.CELSIUS.range(10, 30, 5);
firstValue - the value of the first Temperature to be
included in the returned SortedSet. If this
range method is called on
CELSIUS, firstValue must be
greater than or equal to -273°C and less than or equal to
3000°C; if it is called on FAHRENHEIT
then firstValue must be greater than or equal to
-459.4°F and less than or equal to 5432°F.lastValue - the value of the last Temperature to be included
in the returned SortedSet. This must be greater than
or equal to firstValue. Also, like for
firstValue, if this range method is
called on CELSIUS, lastValue
must be greater than or equal to -273°C and less than or equal
to 3000°C; if it is called on
FAHRENHEIT then lastValue
must be greater than or equal to -459.4°F and less than or
equal to 5432°F.step - the temperature difference between each temperature value to
be included in the returned SortedSet. Cannot be
NaN, and must be greater than zero. It must also be a
multiple of 0.1 (the smallest temperature difference
allowed), though allowances are made for floating-point
imprecision (so for example a step of
0.4999999 will be treated as 0.5).java.lang.IllegalArgumentException - if any of the parameters are
NaN; if firstValue or
lastValue are outside of their allowed range (that's
-273°C to 3000°C inclusive if this range
method is called on CELSIUS, and
-459.4°F to 5432°F inclusive if it is called on
FAHRENHEIT); if lastValue is
less than firstValue; if step is not
positive; or if step is not a multiple of
0.1 (allowing for slight deviations caused by
floating-point imprecision).Temperature.celsiusRange(double, double, double),
Temperature.fahrenheitRange(double, double, double)public java.lang.String toString()
TemperatureUnit in the
request XML ("Celsius" or "Fahrenheit").toString in class java.lang.Enum<TemperatureUnit>public static TemperatureUnit fromString(java.lang.String string) throws java.lang.IllegalArgumentException
java.lang.NullPointerException - if string is null.java.lang.IllegalArgumentException - if string is not one of
"Celsius" or "Fahrenheit".
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.