public final class WeeklyBreakdown extends DatedBreakdown implements java.io.Serializable
DatedBreakdown
used to specify that degree days should be
broken down on a weekly basis and cover a specific Period
in time,
with weeks starting on a specific day of the week.Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Constructor and Description |
---|
WeeklyBreakdown(Period period,
DayOfWeek firstDayOfWeek)
Constructs a
WeeklyBreakdown object that specifies weekly
degree days covering the specified period in time, with each "week"
starting on the specified day of the week. |
Modifier and Type | Method and Description |
---|---|
DayOfWeek |
firstDayOfWeek()
Returns the non-null day of the week that should be the first of each
weekly period.
|
DayRange |
getFullRangeOrNull(DayRange availableDataRange)
Returns the range of days that this breakdown would cover given source
data covering
availableDataRange , or null if
availableDataRange would not be enough for this breakdown. |
Period |
period()
Returns the non-null period in time that the weekly breakdown should
cover.
|
MaybeEmptyDayRanges |
toDayRanges(DayRange availableDataRange)
Returns the breakdown in terms of the day ranges that would constitute it
given source data covering
availableDataRange . |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
WeeklyBreakdown |
withAllowPartialLatest(boolean allowPartialLatest)
Returns a
WeeklyBreakdown with the same period()
and firstDayOfWeek() as this , but with the
DatedBreakdown.allowPartialLatest() property set to the specified value. |
allowPartialLatest, custom, daily, monthly, monthly, weekly, yearly, yearly
public WeeklyBreakdown(Period period, DayOfWeek firstDayOfWeek)
WeeklyBreakdown
object that specifies weekly
degree days covering the specified period in time, with each "week"
starting on the specified day of the week.
To avoid the potential for confusion, you must explicitly specify the day
of the week that you want each "week" to start on. For example, if a
"week" should run from Monday to Sunday (inclusive), specify the
firstDayOfWeek
parameter as DayOfWeek.MONDAY
.
period
- the period in time that the weekly breakdown should cover.
Cannot be null
.firstDayOfWeek
- indicates which day should be taken as the first of
each week. Cannot be null
.java.lang.NullPointerException
- if period
or
firstDayOfWeek
is null
.public Period period()
public DayOfWeek firstDayOfWeek()
public WeeklyBreakdown withAllowPartialLatest(boolean allowPartialLatest)
WeeklyBreakdown
with the same period()
and firstDayOfWeek()
as this
, but with the
DatedBreakdown.allowPartialLatest()
property set to the specified value.
The allowPartialLatest
property makes it possible to fetch
time-series data
(like hourly temperature data) that includes the current (incomplete)
week, including time-series-data values for the current (incomplete) day. It also makes
it possible to fetch weekly degree-day data that includes a
DatedDataValue
for the current week so
far (a partial week). See DatedBreakdown.allowPartialLatest()
for more on how
it works.
allowPartialLatest
- true
to specify that the latest
week of data can be partially filled (i.e. incomplete), or
false
if the latest week must be complete (the
default behaviour).DatedBreakdown.allowPartialLatest()
public MaybeEmptyDayRanges toDayRanges(DayRange availableDataRange)
availableDataRange
.
If you call fullRangeOrNull()
on the return value, you'll get the same result that
you'd get by calling getFullRangeOrNull(availableDataRange)
on this object. Essentially this
method is a more detailed version of getFullRangeOrNull
that
makes sense for dated breakdowns, which translate to real ranges of days
on a calendar (unlike average breakdowns which are broken down into
months of an "average year" rather than applying to a real calendar).
toDayRanges
in class DatedBreakdown
availableDataRange
- the range of temperature data available (or the
available range of daily degree-day data if summing daily degree
days into a different breakdown). Cannot be null
.java.lang.NullPointerException
- if availableDataRange
is
null
.public DayRange getFullRangeOrNull(DayRange availableDataRange)
availableDataRange
, or null
if
availableDataRange
would not be enough for this breakdown.getFullRangeOrNull
in class Breakdown
availableDataRange
- the range of temperature data available (or the
available range of daily degree-day data if summing daily degree
days into a different breakdown). Cannot be null
.java.lang.NullPointerException
- if availableDataRange
is
null
.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.