net.degreedays.api.data
Class DataValue

java.lang.Object
  extended by net.degreedays.api.data.DataValue
Direct Known Subclasses:
DatedDataValue

public abstract class DataValue
extends java.lang.Object

Contains a degree-day value (either HDD or CDD) and an approximate indication of its accuracy.

This abstract class is not designed to be extended by third-party code, which is why it does not have an accessible constructor.

All concrete subclasses of this abstract class are immutable. You can safely reuse them and call them from multiple threads at once.


Method Summary
 boolean equals(java.lang.Object o)
          Returns true if o is a DataValue object of the same type as this with an equal value() and percentageEstimated().
 int hashCode()
          Overridden to ensure consistency with equals.
static DataValue of(double value, double percentageEstimated)
          Returns a non-null DataValue object with the specified configuration.
abstract  double percentageEstimated()
          Returns a number between 0 and 100 (both inclusive), indicating the extent to which the calculated value() is based on estimated data.
 java.lang.String toString()
          Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
abstract  double value()
          Returns the value, which will never be NaN or infinity, and, for degree days, will always be zero or greater.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

value

public abstract double value()
Returns the value, which will never be NaN or infinity, and, for degree days, will always be zero or greater.


percentageEstimated

public abstract double percentageEstimated()
Returns a number between 0 and 100 (both inclusive), indicating the extent to which the calculated value() is based on estimated data.

Generally speaking, a value with a lower percentage-estimated figure is likely to be more reliable than one with a higher percentage-estimated figure.


of

public static DataValue of(double value,
                           double percentageEstimated)
Returns a non-null DataValue object with the specified configuration.

Parameters:
value - indicating the value to be held by the returned object (i.e. the degree days).
percentageEstimated - a number, greater than or equal to zero and less than or equal to 100, indicating the extent to which the value is based on estimated data.
Throws:
java.lang.IllegalArgumentException - if value or percentageEstimated is NaN or infinity, or if percentageEstimated is less than 0 or greater than 100. At the moment an IllegalArgumentException will also be thrown if value is less than zero (since degree-day values are always zero or greater), but this may change in the future if this class is used for other types of data.

equals

public boolean equals(java.lang.Object o)
Returns true if o is a DataValue object of the same type as this with an equal value() and percentageEstimated().

Note that it is not possible for a plain DataValue object to be equal to a DatedDataValue object.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overridden to ensure consistency with equals.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.

The exact details of the representation are unspecified and subject to change.

Overrides:
toString in class java.lang.Object


www.degreedays.net/api/