net.degreedays.api.data.impl
Class YearlyBreakdown

java.lang.Object
  extended by net.degreedays.api.data.Breakdown
      extended by net.degreedays.api.data.DatedBreakdown
          extended by net.degreedays.api.data.impl.YearlyBreakdown
All Implemented Interfaces:
java.io.Serializable

public final class YearlyBreakdown
extends DatedBreakdown
implements java.io.Serializable

A type of DatedBreakdown used to specify that degree days should be broken down on a yearly (annual) basis and cover a specific Period in time.

Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.


Constructor Summary
YearlyBreakdown(Period period)
          Constructs a YearlyBreakdown object that specifies yearly degree days covering the specified period in time and broken down according to regular calendar years.
YearlyBreakdown(Period period, StartOfYear startOfYear)
          Constructs a YearlyBreakdown object that specifies yearly degree days covering the specified period in time, with each "year" starting on the specified day of the year.
 
Method Summary
 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 yearly breakdown should cover.
 StartOfYear startOfYear()
          Returns a non-null StartOfYear object indicating which day should be taken as the first of each year (inclusive).
 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.
 
Methods inherited from class net.degreedays.api.data.DatedBreakdown
daily, monthly, monthly, weekly, yearly, yearly
 
Methods inherited from class net.degreedays.api.data.Breakdown
equals, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

YearlyBreakdown

public YearlyBreakdown(Period period,
                       StartOfYear startOfYear)
Constructs a YearlyBreakdown object that specifies yearly degree days covering the specified period in time, with each "year" starting on the specified day of the year.

Parameters:
period - the period in time that the yearly breakdown should cover. Cannot be null.
startOfYear - specifying which day of the year (month and day of the month) should be taken as the first of each "year". Pass StartOfYear.of(1, 1) to specify regular calendar years. Cannot be null.
Throws:
java.lang.NullPointerException - if period or startOfYear is null.

YearlyBreakdown

public YearlyBreakdown(Period period)
Constructs a YearlyBreakdown object that specifies yearly degree days covering the specified period in time and broken down according to regular calendar years.

This is a shortcut version of this constructor that specifies January the first as the startOfYear parameter.

Parameters:
period - the period in time that the yearly breakdown should cover. Cannot be null.
Throws:
java.lang.NullPointerException - if period is null.
Method Detail

period

public Period period()
Returns the non-null period in time that the yearly breakdown should cover.


startOfYear

public StartOfYear startOfYear()
Returns a non-null StartOfYear object indicating which day should be taken as the first of each year (inclusive).


toDayRanges

public MaybeEmptyDayRanges toDayRanges(DayRange availableDataRange)
Returns the breakdown in terms of the day ranges that would constitute it given source data covering 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).

Specified by:
toDayRanges in class DatedBreakdown
Parameters:
availableDataRange - the non-null range of temperature data available (or the available range of daily degree-day data if summing daily degree days into a different breakdown).
Throws:
java.lang.NullPointerException - if availableDataRange is null.

getFullRangeOrNull

public 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.

Specified by:
getFullRangeOrNull in class Breakdown
Parameters:
availableDataRange - the non-null range of temperature data available (or the available range of daily degree-day data if summing daily degree days into a different breakdown).
Throws:
java.lang.NullPointerException - if availableDataRange is null.

toString

public java.lang.String toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.

The exact details of the representation are unspecified and subject to change.

Overrides:
toString in class java.lang.Object


www.degreedays.net/api/