net.degreedays.api.data
Class DatedBreakdown

java.lang.Object
  extended by net.degreedays.api.data.Breakdown
      extended by net.degreedays.api.data.DatedBreakdown
Direct Known Subclasses:
DailyBreakdown, MonthlyBreakdown, WeeklyBreakdown, YearlyBreakdown

public abstract class DatedBreakdown
extends Breakdown

Defines how a set of dated degree days should be broken down, including the period in time they should cover.

This is the abstract superclass of the types of Breakdown that can be taken by a DatedDataSpec.

To create a DatedBreakdown object you can use the static factory methods of this class. For example:

 DatedBreakdown dailyBreakdownOverLast30Days = 
     DatedBreakdown.daily(Period.latestValues(30));
 
 DatedBreakdown weeklyBreakdownFor2010WithWeeksStartingOnMonday = 
     DatedBreakdown.weekly(
         Period.dayRange(Day.of(2010, 1, 1).to(Day.of(2010, 12, 31))),
         DayOfWeek.MONDAY);
 
 DatedBreakdown monthlyBreakdownOverLast12Months = 
     DatedBreakdown.monthly(Period.latestValues(12));
 
 DatedBreakdown yearlyBreakdownOverLast5Years =
     DatedBreakdown.yearly(Period.latestValues(5));
 

As you can see from the above examples, defining the Period is an important part of defining a DatedBreakdown. See that class for more information on the relevant options.

See Also:
AverageBreakdown

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.


Method Summary
static DailyBreakdown daily(Period period)
          Returns a non-null DailyBreakdown object that specifies daily degree days covering the specified period in time.
static MonthlyBreakdown monthly(Period period)
          Returns a non-null MonthlyBreakdown object that specifies monthly degree days covering the specified period in time and broken down according to regular calendar months.
static MonthlyBreakdown monthly(Period period, StartOfMonth startOfMonth)
          Returns a non-null MonthlyBreakdown object that specifies monthly degree days covering the specified period in time, with each "month" starting on the specified day of the month.
abstract  MaybeEmptyDayRanges toDayRanges(DayRange availableDataRange)
          Returns the breakdown in terms of the day ranges that would constitute it given source data covering availableDataRange.
static WeeklyBreakdown weekly(Period period, DayOfWeek firstDayOfWeek)
          Returns a non-null WeeklyBreakdown object that specifies weekly degree days covering the specified period in time, with each "week" starting on the specified day of the week.
static YearlyBreakdown yearly(Period period)
          Returns a non-null YearlyBreakdown object that specifies yearly degree days covering the specified period in time and broken down according to regular calendar years.
static YearlyBreakdown yearly(Period period, StartOfYear startOfYear)
          Returns a non-null YearlyBreakdown object that specifies yearly degree days covering the specified period in time, with each "year" starting on the specified day of the year.
 
Methods inherited from class net.degreedays.api.data.Breakdown
equals, getFullRangeOrNull, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

daily

public static DailyBreakdown daily(Period period)
Returns a non-null DailyBreakdown object that specifies daily degree days covering the specified period in time.

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

weekly

public static WeeklyBreakdown weekly(Period period,
                                     DayOfWeek firstDayOfWeek)
Returns a non-null 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.

Parameters:
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.
Throws:
java.lang.NullPointerException - if period or firstDayOfWeek is null.

monthly

public static MonthlyBreakdown monthly(Period period,
                                       StartOfMonth startOfMonth)
Returns a non-null MonthlyBreakdown object that specifies monthly degree days covering the specified period in time, with each "month" starting on the specified day of the month.

Parameters:
period - the period in time that the monthly breakdown should cover. Cannot be null.
startOfMonth - specifying which day (between 1 and 28 inclusive) should be taken as the first of each "month". Pass StartOfMonth.of(1) to specify regular calendar months. Cannot be null.
Throws:
java.lang.NullPointerException - if period or startOfMonth is null.

monthly

public static MonthlyBreakdown monthly(Period period)
Returns a non-null MonthlyBreakdown object that specifies monthly degree days covering the specified period in time and broken down according to regular calendar months.

This is a shortcut version of this method that specifies the first day of the month as the startOfMonth parameter.

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

yearly

public static YearlyBreakdown yearly(Period period,
                                     StartOfYear startOfYear)
Returns a non-null 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.

yearly

public static YearlyBreakdown yearly(Period period)
Returns a non-null 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 method 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.

toDayRanges

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

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.


www.degreedays.net/api/