public final class DataSets
extends java.lang.Object
implements java.io.Serializable
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
| Modifier and Type | Class and Description |
|---|---|
static class |
DataSets.Builder
A builder class for creating immutable
DataSets objects
e.g. for testing purposes. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
A
DataSets object is equal to another DataSets
object with an equal DataSet for each DataSpec that
it was created with. |
DataSet |
get(DataSpec dataSpec)
Returns the
DataSet that was generated to fulfil the
specified DataSpec from the request, or throws a
SourceDataException if no such DataSet could be
generated. |
AverageDataSet |
getAverage(AverageDataSpec dataSpec)
Returns the
AverageDataSet that was generated to fulfil the
specified AverageDataSpec from the request, or throws a
SourceDataException if no such AverageDataSet could
be generated. |
DatedDataSet |
getDated(DatedDataSpec dataSpec)
Returns the
DatedDataSet that was generated to fulfil the
specified DatedDataSpec from the request, or throws a
SourceDataException if no such DatedDataSet could be
generated. |
TimeSeriesDataSet |
getTimeSeries(TimeSeriesDataSpec dataSpec)
Returns the
TimeSeriesDataSet that was generated to fulfil
the specified TimeSeriesDataSpec from the request, or throws
a SourceDataException if no such TimeSeriesDataSet
could be generated. |
DataSet |
getWithKey(java.lang.String key)
For unusual use cases, this enables you to access the
DataSet objects using the string keys that are usually
managed internally. |
int |
hashCode()
Overridden to ensure consistency with
equals. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
public DataSet get(DataSpec dataSpec) throws SourceDataException
DataSet that was generated to fulfil the
specified DataSpec from the request, or throws a
SourceDataException if no such DataSet could be
generated.dataSpec - a DataSpec from the request.DataSet that was generated to fulfil
dataSpec.SourceDataException - if the API's processing of
dataSpec failed.java.lang.NullPointerException - if dataSpec is
null.java.lang.IllegalArgumentException - if dataSpec is not a
DataSpec from the original request.java.lang.IllegalStateException - if this DataSets object was
not created with access to the DataSpecs object from the
request (this won't be an issue if you are using this framework
end to end).getDated(DatedDataSpec),
getAverage(AverageDataSpec),
getTimeSeries(TimeSeriesDataSpec)public DatedDataSet getDated(DatedDataSpec dataSpec) throws SourceDataException
DatedDataSet that was generated to fulfil the
specified DatedDataSpec from the request, or throws a
SourceDataException if no such DatedDataSet could be
generated.
This is a convenience alternative to calling get(DataSpec) with
a DatedDataSpec and then casting the result.
dataSpec - a DatedDataSpec from the request.DatedDataSet that was generated to fulfil
dataSpec.SourceDataException - if the API's processing of
dataSpec failed.java.lang.NullPointerException - if dataSpec is
null.java.lang.IllegalArgumentException - if dataSpec is not a
DataSpec from the original request.java.lang.IllegalStateException - if this DataSets object was
not created with access to the DataSpecs object from the
request (this won't be an issue if you are using this framework
end to end).getAverage(AverageDataSpec),
getTimeSeries(TimeSeriesDataSpec),
get(DataSpec)public AverageDataSet getAverage(AverageDataSpec dataSpec) throws SourceDataException
AverageDataSet that was generated to fulfil the
specified AverageDataSpec from the request, or throws a
SourceDataException if no such AverageDataSet could
be generated.
This is a convenience alternative to calling get(DataSpec) with
an AverageDataSpec and then casting the result.
dataSpec - an AverageDataSpec from the request.AverageDataSet that was generated to fulfil
dataSpec.SourceDataException - if the API's processing of
dataSpec failed.java.lang.NullPointerException - if dataSpec is
null.java.lang.IllegalArgumentException - if dataSpec is not a
DataSpec from the original request.java.lang.IllegalStateException - if this DataSets object was
not created with access to the DataSpecs object from the
request (this won't be an issue if you are using this framework
end to end).getDated(DatedDataSpec),
getTimeSeries(TimeSeriesDataSpec),
get(DataSpec)public TimeSeriesDataSet getTimeSeries(TimeSeriesDataSpec dataSpec) throws SourceDataException
TimeSeriesDataSet that was generated to fulfil
the specified TimeSeriesDataSpec from the request, or throws
a SourceDataException if no such TimeSeriesDataSet
could be generated.
This is a convenience alternative to calling get(DataSpec) with
a TimeSeriesDataSpec and then casting the result.
dataSpec - a TimeSeriesDataSpec from the request.TimeSeriesDataSet that was generated to
fulfil dataSpec.SourceDataException - if the API's processing of
dataSpec failed.java.lang.NullPointerException - if dataSpec is
null.java.lang.IllegalArgumentException - if dataSpec is not a
DataSpec from the original request.java.lang.IllegalStateException - if this DataSets object was
not created with access to the DataSpecs object from the
request (this won't be an issue if you are using this framework
end to end).getDated(DatedDataSpec),
getAverage(AverageDataSpec),
get(DataSpec)public DataSet getWithKey(java.lang.String key) throws SourceDataException
For unusual use cases, this enables you to access the
DataSet objects using the string keys that are usually
managed internally.
Usually you'll want the methods that take a DataSpec (or
subclass) instead of this one, but you might need this method if you are:
DataSpecs yourself; orResponseParser
that you have written.key - a non-null, non-empty string key that you expect to be present
in the response, associated with the set of data that you want to
access.DataSet associated with key
(matching a data specification with key key from the
original request).SourceDataException - if there was a failure in the API's
processing of the data specification associated with
key.java.lang.NullPointerException - if key is null.java.lang.IllegalArgumentException - if key isn't recognized as
a key from this response.getDated(DatedDataSpec),
getAverage(AverageDataSpec),
getTimeSeries(TimeSeriesDataSpec),
get(DataSpec)public boolean equals(java.lang.Object o)
A DataSets object is equal to another DataSets
object with an equal DataSet for each DataSpec that
it was created with.
If this DataSets object was created without a
DataSpecs object, then it can only be equal to another
DataSets object that was created without a
DataSpecs object, and that has equal keys and an equal
DataSet object for each of those keys.
equals in class java.lang.Objectpublic int hashCode()
equals.hashCode in class java.lang.Objectpublic java.lang.String toString()
The exact details of the representation are unspecified and subject to change.
toString 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.