net.degreedays.api.data
Class Period

java.lang.Object
  extended by net.degreedays.api.data.Period
Direct Known Subclasses:
DayRangePeriod, LatestValuesPeriod

public abstract class Period
extends java.lang.Object

Defines the period in time that a set of degree days should cover.

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
static DayRangePeriod dayRange(DayRange dayRange)
          Returns a non-null DayRangePeriod object that specifies the period covered by dayRange.
 boolean equals(java.lang.Object o)
          Two Period objects are equal if it can be ascertained that they will always represent the same period in time as each other when compared at the same time and in the same context.
 int hashCode()
          Overridden to ensure consistency with equals.
static LatestValuesPeriod latestValues(int numberOfValues)
          Returns a non-null LatestValuesPeriod object that automatically resolves to a date range including the latest available data and the specified number of degree-day values.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

dayRange

public static DayRangePeriod dayRange(DayRange dayRange)
Returns a non-null DayRangePeriod object that specifies the period covered by dayRange.

Parameters:
dayRange - the range of days that the period should cover. Cannot be null.
Throws:
java.lang.NullPointerException - if dayRange is null.

latestValues

public static LatestValuesPeriod latestValues(int numberOfValues)
Returns a non-null LatestValuesPeriod object that automatically resolves to a date range including the latest available data and the specified number of degree-day values.

Parameters:
numberOfValues - a number, greater than zero, that specifies how many degree-day values the period should cover (see this explanation of how the values in question can be daily, weekly, monthly, or yearly). This is effectively an upper bound: if there isn't enough good data to cover the numberOfValues specified, the API will assemble and return what it can.
Throws:
java.lang.IllegalArgumentException - if numberOfValues is less than or equal to zero.

equals

public final boolean equals(java.lang.Object o)
Two Period objects are equal if it can be ascertained that they will always represent the same period in time as each other when compared at the same time and in the same context.

If this method returns false, it is still possible that the two Period objects could represent the same period in time if compared at a certain time and in a certain context. For example, it is possible for a LatestValuesPeriod to translate to the same date range as a DayRangePeriod, but that is dependent on the time of comparison and the time at the location for which the data is being specified. This equals method does not attempt to look for transient equality like that - if the "equality" is dependent on time or context this method will always return false.

Overrides:
equals in class java.lang.Object
Returns:
true if o is a Period that will always represent the same period in time as this Period when compared at the same time and in the same context, or false otherwise.

hashCode

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

Overrides:
hashCode in class java.lang.Object


www.degreedays.net/api/