Class HolidayCalendarFactory

java.lang.Object
org.holiday.calendar.HolidayCalendarFactory

public class HolidayCalendarFactory extends Object
Factory for creation of HolidayCalendar objects.
Author:
Dave Joyce
  • Constructor Details

    • HolidayCalendarFactory

      public HolidayCalendarFactory()
  • Method Details

    • create

      public HolidayCalendar create(String code)
      Create (or return cached) HolidayCalendar identified by the specified code.
      Parameters:
      code - short code identifier of desired holiday calendar
      Returns:
      holiday calendar
      Throws:
      HolidayCalendarNotFoundException - if code does not match any available holiday calendar
    • getService

      public HolidayCalendarService getService(String code)
      Get the HolidayCalendarService object that provides the HolidayCalendar object identified by the specified code.
      Parameters:
      code - short code identifier of desired holiday calendar
      Returns:
      holiday calendar service
      Throws:
      HolidayCalendarNotFoundException - if code does not match any available holiday calendar service
    • listAvailableCodes

      public List<String> listAvailableCodes()
      List all calendar codes available from registered services.
      Returns:
      sorted list of available calendar codes
    • dataValidThrough

      public OptionalInt dataValidThrough(String code)
      Returns the latest year for which the calendar identified by code provides authoritative data, by delegating to HolidayCalendarService.dataValidThrough() on the service that provides that code.

      An empty result means the calendar is fully algorithmic with no known upper bound. A non-empty result means at least one holiday in the calendar is backed by a lookup table that ends at the returned year; calculations for later years will silently omit those holidays.

      Parameters:
      code - short code identifier of the desired holiday calendar
      Returns:
      the last authoritative year, or OptionalInt.empty() if the calendar is fully algorithmic with no known upper bound
      Throws:
      HolidayCalendarNotFoundException - if code does not match any registered service