- java.lang.Object
-
- de.focus_shift.jollyday.core.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.- Version:
- $Id: $
- Author:
- Sven Diedrichsen
-
-
Field Summary
Fields Modifier and Type Field Description protected CalendarUtilcalendarUtilUtility for calendar operations
-
Constructor Summary
Constructors Constructor Description HolidayManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static voidclearManagerCache()Clears the manager cache from all cached manager instances.abstract voiddoInit()abstract CalendarHierarchygetCalendarHierarchy()Returns the configured hierarchy structure for the specific manager.ConfigurationServicegetConfigurationService()Returns theConfigurationServiceto be used to retrieve holiday data.abstract Set<Holiday>getHolidays(int year, String... args)Returns the holidays for the requested year and hierarchy structure.abstract Set<Holiday>getHolidays(LocalDate startDateInclusive, LocalDate endDateInclusive, String... args)Returns the holidays for the requested interval and hierarchy structure.static HolidayManagergetInstance()Creates a HolidayManager instance for the default locale country using the configured properties from the configuration file.static HolidayManagergetInstance(ManagerParameter parameter)Creates and returns aHolidayManagerfor the providedManagerParametersstatic HolidayManagergetInstance(Properties properties)Creates a HolidayManager instance for the default locale country using the provided properties.ManagerParametergetManagerParameter()static Set<String>getSupportedCalendarCodes()Returns a set of all currently supported calendar codes.voidinit(ManagerParameter parameters)Initializes the implementing manager for the provided calendar.booleanisHoliday(LocalDate c, HolidayType holidayType, String... args)Show if the requested date is a holiday.booleanisHoliday(LocalDate c, String... args)Calls #isHoliday(c, null, args)booleanisHoliday(Calendar c, HolidayType holidayType, String... args)Calls isHoliday withLocalDateobject.booleanisHoliday(Calendar c, String... args)static booleanisManagerCachingEnabled()isManagerCachingEnabled.voidsetConfigurationService(ConfigurationService configurationService)Sets the configuration datasource with this holiday manager.static voidsetManagerCachingEnabled(boolean managerCachingEnabled)If true, instantiated managers will be cached.
-
-
-
Field Detail
-
calendarUtil
protected final CalendarUtil calendarUtil
Utility for calendar operations
-
-
Method Detail
-
getInstance
public static HolidayManager getInstance()
Creates a HolidayManager instance for the default locale country using the configured properties from the configuration file.- Returns:
- a 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:
- a eventually cached HolidayManager instance
-
getInstance
public static HolidayManager getInstance(ManagerParameter parameter)
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
public boolean isHoliday(Calendar c, HolidayType holidayType, String... args)
Calls isHoliday withLocalDateobject.
-
isHoliday
public boolean isHoliday(LocalDate c, HolidayType holidayType, String... args)
Show if the requested date is a holiday.- Parameters:
c- The potential holiday.holidayType- aHolidayTypeobjectargs- Hierarchy to request the holidays for. i.e. args = {'ny'} -> New York holidays- Returns:
- is a holiday in the state/region
-
isHoliday
public boolean isHoliday(LocalDate c, String... args)
Calls #isHoliday(c, null, args)- Parameters:
c- the date to checkargs- the arguments to find the calendar- Returns:
- whether the date is a holiday
-
getSupportedCalendarCodes
public static Set<String> getSupportedCalendarCodes()
Returns a set of all currently supported calendar codes.- Returns:
- Set of supported calendar codes.
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
Sets the configuration datasource with this holiday manager.- Parameters:
configurationService- theConfigurationServiceto use.
-
getConfigurationService
public ConfigurationService getConfigurationService()
Returns theConfigurationServiceto be used to retrieve holiday data.- Returns:
- the
ConfigurationServiceto use.
-
getManagerParameter
public ManagerParameter getManagerParameter()
-
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()
-
getHolidays
public abstract Set<Holiday> getHolidays(int year, String... args)
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 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, inclusiveendDateInclusive- the end date of the interval in which holidays lie, inclusiveargs- aStringobject.- Returns:
- list of holidays 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
-
-