public final class RegressionResponse extends Response implements java.io.Serializable
RegressionRequest
, with the Regression
that gave the best
statistical fit listed first.RegressionApi.runRegressions(RegressionRequest)
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 |
RegressionResponse.Builder
A builder class for creating immutable
RegressionResponse objects
e.g. for testing purposes. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Returns
true if o is a
RegressionResponse with equal values apart from the
metadata() (which is not considered in the equality
test). |
java.util.List<Regression> |
getRegressions()
Returns a non-null, non-empty, best-first ordered list of
Regression objects, or throws a SourceDataException
if the API could not generate regressions because there was not enough
good weather data for the Location specified in your
RegressionRequest . |
Source[] |
getSources()
Returns the non-null, non-empty array of source(s) (essentially weather
stations) that were used to generate the degree days used for the
regressions in this response.
|
int |
hashCode()
Overridden to ensure consistency with
equals . |
java.lang.String |
stationId()
Returns the non-null, non-empty canonical ID of the weather station or
combination of weather stations that supplied the temperature data used
to calculate the degree days used for the regressions in this response.
|
LongLat |
targetLongLat()
Returns the non-null
LongLat object that specifies the
geographic position of the Location from the
RegressionRequest that led to this response. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
public java.lang.String stationId()
InputData
provided in the request.
If the Location
in the RegressionRequest
was a
StationIdLocation
, this method will simply return the canonical
form of that weather station's ID. We say "canonical" because it's
possible for a station ID to be expressed in more than one way, like
upper case or lower case. The canonical form of the station ID is the
form that you should display in a UI or store in a database if
appropriate.
If the Location
in the RegressionRequest
was a
GeographicLocation
, then:
Either way, the station ID returned by this method can be used to run
more regressions or fetch more data from the same station(s) that were
used to generate the degree days used for the regressions in this
response. For example, you might want to start off using a
GeographicLocation
initially, and then use the returned
station ID to fetch more data or run more regressions using the same
station.
public LongLat targetLongLat()
LongLat
object that specifies the
geographic position of the Location
from the
RegressionRequest
that led to this response.
If the Location
from the request was a
PostalCodeLocation
, this will
return the LongLat
that the API determined to be the central
point of that postal code.
If the Location
from the request was a
StationIdLocation
, this will return the LongLat
of that station (also accessible through getSources()
).
If the Location
from the request was a
LongLatLocation
, this will
simply return the LongLat
that was originally specified.
(Bear in mind that the longitude and latitude may have been rounded
slightly between the request and the response. Such rounding would only
introduce very small differences that would be insignificant as far as
the real-world position is concerned, but it's worth bearing this in mind
in case you are comparing for equality the returned LongLat
with the LongLat
from the request. The two positions will be
close, but they might not be equal.)
public Source[] getSources()
InputData
provided in the request.
At the time of writing there will only be one source for any given
response (so getSources()[0]
is the way to get it)... But at
some point we might start combining data from multiple sources to satisfy
requests for data from geographic
locations. If we do add this feature, it will be optional, and disabled
by default, so the behaviour of your system won't change unless you want
it to.
The returned array can be modified freely without affecting the
immutability of this RegressionResponse
or the arrays
returned by past, concurrent, or future calls to this method.
public java.util.List<Regression> getRegressions() throws SourceDataException
Regression
objects, or throws a SourceDataException
if the API could not generate regressions because there was not enough
good weather data for the Location
specified in your
RegressionRequest
.SourceDataException
- if the API could not generate any regressions
because there wasn't enough good weather data available for the
Location
specified in your RegressionRequest
.public boolean equals(java.lang.Object o)
true
if o
is a
RegressionResponse
with equal values apart from the
metadata()
(which is not considered in the equality
test).equals
in class java.lang.Object
public int hashCode()
equals
.hashCode
in class java.lang.Object
public 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.