public abstract class Period
extends java.lang.Object
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.
Modifier and Type | Method and Description |
---|---|
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. |
public static DayRangePeriod dayRange(DayRange dayRange)
DayRangePeriod
object that specifies the
period covered by dayRange
.dayRange
- the range of days that the period should cover. Cannot be
null
.java.lang.NullPointerException
- if dayRange
is
null
.public static LatestValuesPeriod latestValues(int numberOfValues)
LatestValuesPeriod
object that
automatically resolves to a date range including the latest available
data and the specified number of degree-day values.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.java.lang.IllegalArgumentException
- if numberOfValues
is less
than or equal to zero.public final boolean equals(java.lang.Object o)
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
.
equals
in class java.lang.Object
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.public final int hashCode()
equals
.hashCode
in class java.lang.Object
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.