public abstract class DataSpec
extends java.lang.Object
A DataSpec
defines a single set of data only (e.g. degree days
in just one base temperature), but the DataSpecs
class will enable
you to include multiple DataSpec
objects in a single
LocationDataRequest
.
To create a DataSpec
object you can use the static
factory methods of this class. For example:
DatedDataSpec thirtyMostRecentHddValues = DataSpec.dated(
Calculation.heatingDegreeDays(Temperature.fahrenheit(55)),
DatedBreakdown.daily(Period.latestValues(30)));
AverageDataSpec fiveYearAverageCdd = DataSpec.average(
Calculation.coolingDegreeDays(Temperature.fahrenheit(65)),
AverageBreakdown.fullYears(Period.latestValues(5)));
TimeSeriesDataSpec hourlyTempsForLastCalendarYear = DataSpec.timeSeries(
TimeSeriesCalculation.hourlyTemperature(TemperatureUnit.CELSIUS),
DatedBreakdown.yearly(Period.latestValues(1)));
See DatedDataSpec
, AverageDataSpec
, and
TimeSeriesDataSpec
for example code showing how to use each one
individually to fetch data from the API. Though do remember that, as
mentioned above, you can also fetch multiple sets of data in a single
request.
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 AverageDataSpec |
average(Calculation calculation,
AverageBreakdown averageBreakdown)
Returns a non-null
AverageDataSpec object with the
specified Calculation and AverageBreakdown . |
static DatedDataSpec |
dated(Calculation calculation,
DatedBreakdown datedBreakdown)
Returns a non-null
DatedDataSpec object with the specified
Calculation and DatedBreakdown . |
boolean |
equals(java.lang.Object o)
Two
DataSpec objects are equal if they have the same class
and the same configuration. |
int |
hashCode()
Overridden to ensure consistency with
equals . |
static TimeSeriesDataSpec |
timeSeries(TimeSeriesCalculation timeSeriesCalculation,
DatedBreakdown datedBreakdown)
Returns a non-null
TimeSeriesDataSpec object with the
specified TimeSeriesCalculation and
DatedBreakdown . |
public static DatedDataSpec dated(Calculation calculation, DatedBreakdown datedBreakdown)
DatedDataSpec
object with the specified
Calculation
and DatedBreakdown
.calculation
- defines the way in which the degree days should be
calculated in terms of their base temperature and whether they
should be heating degree days or cooling degree days. Cannot be
null
.datedBreakdown
- defines the way in which the data should be broken
down and the period that it should cover. Cannot be
null
.java.lang.NullPointerException
- if calculation
or
datedBreakdown
is null
.DatedDataSpec
,
average(Calculation, AverageBreakdown)
,
timeSeries(TimeSeriesCalculation, DatedBreakdown)
public static AverageDataSpec average(Calculation calculation, AverageBreakdown averageBreakdown)
AverageDataSpec
object with the
specified Calculation
and AverageBreakdown
.calculation
- defines the way in which the degree days should be
calculated in terms of their base temperature and whether they
should be heating degree days or cooling degree days. Cannot be
null
.averageBreakdown
- defines the way in which the data should be
broken down and the period that it should cover. Cannot be
null
.java.lang.NullPointerException
- if calculation
or
averageBreakdown
is null
.AverageDataSpec
,
dated(Calculation, DatedBreakdown)
,
timeSeries(TimeSeriesCalculation, DatedBreakdown)
public static TimeSeriesDataSpec timeSeries(TimeSeriesCalculation timeSeriesCalculation, DatedBreakdown datedBreakdown)
TimeSeriesDataSpec
object with the
specified TimeSeriesCalculation
and
DatedBreakdown
.timeSeriesCalculation
- defines how the time-series data should be
calculated (e.g.
specifying hourly temperature data, in Celsius). Cannot be
null
.datedBreakdown
- defines the period of time that the time-series
data should cover (read more on how this
works). Cannot be null
.java.lang.NullPointerException
- if timeSeriesCalculation
or
datedBreakdown
is null
.TimeSeriesDataSpec
,
dated(Calculation, DatedBreakdown)
,
average(Calculation, AverageBreakdown)
public final boolean equals(java.lang.Object o)
DataSpec
objects are equal if they have the same class
and the same configuration.equals
in class java.lang.Object
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.