Class HolidayManager


  • public abstract class HolidayManager
    extends Object
    Abstract base class for all holiday manager implementations. Upon call of getInstance method the implementing class will be read from the jollyday.properties file and instantiated.
    • Constructor Detail

      • HolidayManager

        public HolidayManager()
    • Method Detail

      • init

        public void init​(ManagerParameter parameters)
        Initializes the implementing manager for the provided calendar.
        Parameters:
        parameters - i.e. us, uk, de
      • doInit

        public abstract void doInit()
      • getInstance

        public static HolidayManager getInstance()
        Creates a HolidayManager instance for the default locale country using the configured properties from the configuration file.
        Returns:
        an eventually cached HolidayManager instance
      • getInstance

        public static HolidayManager getInstance​(Properties properties)
        Creates a HolidayManager instance for the default locale country using the provided properties.
        Parameters:
        properties - the overriding configuration properties.
        Returns:
        an eventually cached HolidayManager instance
      • setManagerCachingEnabled

        public static void setManagerCachingEnabled​(boolean managerCachingEnabled)
        If true, instantiated managers will be cached. If false every call to getInstance will create new manager. True by default.
        Parameters:
        managerCachingEnabled - the managerCachingEnabled to set
      • isManagerCachingEnabled

        public static boolean isManagerCachingEnabled()

        isManagerCachingEnabled.

        Returns:
        the CACHING_ENABLED
      • clearManagerCache

        public static void clearManagerCache()
        Clears the manager cache from all cached manager instances.
      • isHoliday

        public boolean isHoliday​(Calendar calendar,
                                 String... args)
        Returns true or false if the requested calendar date is a holiday in the state or the optional given region and below
        Parameters:
        calendar - Calendar to check.
        args - Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays
        Returns:
        if the date is a holiday
      • isHoliday

        public boolean isHoliday​(Calendar calendar,
                                 HolidayType holidayType,
                                 String... args)
        Returns true or false if the requested calendar date is a holiday in the state or based on the given HolidayType and the optional given region and below
        Parameters:
        calendar - Calendar to check.
        holidayType - a HolidayType to be considered
        args - Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays
        Returns:
        if the date is a holiday
      • isHoliday

        public boolean isHoliday​(LocalDate localDate,
                                 String... args)
        Returns true or false if the requested date is a holiday in the state or the optional given region and below
        Parameters:
        localDate - The potential holiday.
        args - Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays
        Returns:
        true if the given date is a holiday in the state/region and below, otherwise false
      • isHoliday

        public boolean isHoliday​(LocalDate localDate,
                                 HolidayType holidayType,
                                 String... args)
        Returns true or false if the requested date is a holiday in the state, based on the given HolidayType and the optional given region and below
        Parameters:
        localDate - The potential holiday.
        holidayType - a HolidayType to be considered
        args - Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays
        Returns:
        true if the given date is a holiday in the state/region and below, otherwise false
      • getSupportedCalendarCodes

        public static Set<String> getSupportedCalendarCodes()
        Returns a set of all currently supported ISO 3166-1 alpha-2 codes.
        Returns:
        Set of supported calendar codes.
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)
        Sets the configuration datasource with this holiday manager.
        Parameters:
        configurationService - the ConfigurationService to use.
      • getHolidays

        public abstract Set<Holiday> getHolidays​(Year year,
                                                 String... args)
        Returns the holidays for the requested year and hierarchy structure.
        Parameters:
        year - i.e. 2010
        args - i.e. args = {'ny'}. returns US/New York holidays. No args means holidays common to whole country
        Returns:
        a set of holidays for the requested year
      • getHolidays

        public abstract Set<Holiday> getHolidays​(Year year,
                                                 HolidayType holidayType,
                                                 String... args)
        Returns the holidays for the requested year, the given HolidayType and the hierarchy structure
        Parameters:
        year - i.e. 2010
        holidayType - a HolidayType to be considered
        args - i.e. args = {'ny'}. returns US/New York holidays. No args means holidays common to whole country
        Returns:
        a set of holidays of the given HolidayType for the requested year
      • getHolidays

        public abstract Set<Holiday> getHolidays​(LocalDate startDateInclusive,
                                                 LocalDate endDateInclusive,
                                                 String... args)
        Returns the holidays for the requested interval and hierarchy structure.
        Parameters:
        startDateInclusive - the start date of the interval in which holidays lie, inclusive
        endDateInclusive - the end date of the interval in which holidays lie, inclusive
        args - i.e. args = {'ny'}. returns US/New York holidays. No args means holidays common to whole country
        Returns:
        set of holidays within the interval
      • getHolidays

        public abstract Set<Holiday> getHolidays​(LocalDate startDateInclusive,
                                                 LocalDate endDateInclusive,
                                                 HolidayType holidayType,
                                                 String... args)
        Returns the holidays for the requested interval, the given HolidayType and hierarchy structure.
        Parameters:
        startDateInclusive - the start date of the interval in which holidays lie, inclusive
        endDateInclusive - the end date of the interval in which holidays lie, inclusive
        holidayType - a HolidayType to be considered
        args - i.e. args = {'ny'}. returns US/New York holidays. No args means holidays common to whole country
        Returns:
        set of holidays of the given HolidayType within the interval
      • getCalendarHierarchy

        public abstract CalendarHierarchy getCalendarHierarchy()
        Returns the configured hierarchy structure for the specific manager. This hierarchy shows how the configured holidays are structured and can be retrieved.
        Returns:
        Current calendars hierarchy