java.lang.Object
de.focus_shift.jollyday.core.HolidayManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the manager cache from all cached manager instances.abstract voiddoInit()abstract @NonNull CalendarHierarchyReturns the configured hierarchy structure for the specific manager.@NonNull HolidayCalendarConfigurationServiceReturns theHolidayCalendarConfigurationServiceto be used to retrieve holiday data.getHolidays(@NonNull LocalDate startDateInclusive, @NonNull LocalDate endDateInclusive, @NonNull HolidayType holidayType, @NonNull String... args) Returns the holidays for the requested interval, the givenHolidayTypeand hierarchy structure.getHolidays(@NonNull LocalDate startDateInclusive, @NonNull LocalDate endDateInclusive, @NonNull String... args) Returns the holidays for the requested interval and hierarchy structure.getHolidays(@NonNull Year year, @NonNull HolidayType holidayType, @NonNull String... args) Returns the holidays for the requested year, the givenHolidayTypeand the hierarchy structuregetHolidays(@NonNull Year year, @NonNull String... args) Returns the holidays for the requested year and hierarchy structure.static @NonNull HolidayManagerCreates a HolidayManager instance for the default locale country using the configured properties from the configuration file.static @NonNull HolidayManagergetInstance(@NonNull ManagerParameter parameter) Creates and returns aHolidayManagerfor the providedManagerParametersstatic @NonNull HolidayManagergetInstance(@NonNull Properties properties) Creates a HolidayManager instance for the default locale country using the provided properties.@NonNull ManagerParameterReturns theManagerParameterto be usedvoidinit(@NonNull ManagerParameter parameters) Initializes the implementing manager for the provided calendar.booleanReturns true or false if the requested date is a holiday in the state or the optional given region and belowbooleanisHoliday(@NonNull LocalDate localDate, @Nullable HolidayType holidayType, @NonNull String... args) Returns true or false if the requested date is a holiday in the state, based on the givenHolidayTypeand the optional given region and belowbooleanReturns true or false if the requested calendar date is a holiday in the state or the optional given region and belowbooleanisHoliday(@NonNull Calendar calendar, @Nullable HolidayType holidayType, @NonNull String... args) Returns true or false if the requested calendar date is a holiday in the state or based on the givenHolidayTypeand the optional given region and belowstatic booleanisManagerCachingEnabled.voidsetConfigurationService(@NonNull HolidayCalendarConfigurationService configurationService) Sets the configuration datasource with this holiday manager.static voidsetManagerCachingEnabled(boolean managerCachingEnabled) If true, instantiated managers will be cached.
-
Constructor Details
-
HolidayManager
public HolidayManager()
-
-
Method Details
-
init
Initializes the implementing manager for the provided calendar.- Parameters:
parameters- i.e. us, uk, de
-
doInit
public abstract void doInit() -
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
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
-
getInstance
Creates and returns aHolidayManagerfor the providedManagerParameters- Parameters:
parameter- theManagerParametersto create the manager with- Returns:
- the
HolidayManagerinstance
-
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
Returns true or false if the requested calendar date is a holiday in the state or the optional given region and below- Parameters:
calendar-Calendarto 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(@NonNull Calendar calendar, @Nullable HolidayType holidayType, @NonNull String... args) Returns true or false if the requested calendar date is a holiday in the state or based on the givenHolidayTypeand the optional given region and below- Parameters:
calendar-Calendarto check.holidayType- aHolidayTypeto be consideredargs- Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays- Returns:
- if the date is a holiday
-
isHoliday
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(@NonNull LocalDate localDate, @Nullable HolidayType holidayType, @NonNull String... args) Returns true or false if the requested date is a holiday in the state, based on the givenHolidayTypeand the optional given region and below- Parameters:
localDate- The potential holiday.holidayType- aHolidayTypeto be consideredargs- 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
-
setConfigurationService
public void setConfigurationService(@NonNull HolidayCalendarConfigurationService configurationService) Sets the configuration datasource with this holiday manager.- Parameters:
configurationService- theHolidayCalendarConfigurationServiceto use.
-
getConfigurationService
Returns theHolidayCalendarConfigurationServiceto be used to retrieve holiday data.- Returns:
- the
HolidayCalendarConfigurationServiceto use.
-
getManagerParameter
Returns theManagerParameterto be used- Returns:
- the
ManagerParameterto use.
-
getHolidays
Returns the holidays for the requested year and hierarchy structure.- Parameters:
year- i.e. 2010args- 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 @NonNull Set<Holiday> getHolidays(@NonNull Year year, @NonNull HolidayType holidayType, @NonNull String... args) Returns the holidays for the requested year, the givenHolidayTypeand the hierarchy structure- Parameters:
year- i.e. 2010holidayType- aHolidayTypeto be consideredargs- 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
HolidayTypefor the requested year
-
getHolidays
public abstract @NonNull Set<Holiday> getHolidays(@NonNull LocalDate startDateInclusive, @NonNull LocalDate endDateInclusive, @NonNull String... args) Returns the holidays for the requested interval and hierarchy structure.- Parameters:
startDateInclusive- the start date of the interval in which holidays lie, inclusiveendDateInclusive- the end date of the interval in which holidays lie, inclusiveargs- 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 @NonNull Set<Holiday> getHolidays(@NonNull LocalDate startDateInclusive, @NonNull LocalDate endDateInclusive, @NonNull HolidayType holidayType, @NonNull String... args) Returns the holidays for the requested interval, the givenHolidayTypeand hierarchy structure.- Parameters:
startDateInclusive- the start date of the interval in which holidays lie, inclusiveendDateInclusive- the end date of the interval in which holidays lie, inclusiveholidayType- aHolidayTypeto be consideredargs- i.e. args = {'ny'}. returns US/New York holidays. No args means holidays common to whole country- Returns:
- set of holidays of the given
HolidayTypewithin the interval
-
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
-