net.objectlab.kit.datecalc.common
Class AbstractKitCalculatorsFactory<E>

java.lang.Object
  extended by net.objectlab.kit.datecalc.common.AbstractKitCalculatorsFactory<E>
Type Parameters:
E - a representation of a date, typically JDK: Date, Calendar; Joda:LocalDate, YearMonthDay
All Implemented Interfaces:
KitCalculatorsFactory<E>

public abstract class AbstractKitCalculatorsFactory<E>
extends java.lang.Object
implements KitCalculatorsFactory<E>

Base class for all calculator factories, it handles the holiday registration.


Constructor Summary
AbstractKitCalculatorsFactory()
           
 
Method Summary
 HolidayCalendar<E> getHolidayCalendar(java.lang.String name)
           
 boolean isHolidayCalendarRegistered(java.lang.String name)
           
 void registerHolidays(java.lang.String name, HolidayCalendar<E> holidaysCalendar)
          Use this method to register a given calendar, it will replace any existing one with the same name.
 void registerHolidays(java.lang.String name, java.util.Set<E> holidaysSet)
          Deprecated. use the HolidayCalendar
protected  void setHolidays(java.lang.String name, DateCalculator<E> dc)
          Used by extensions to set holidays in a DateCalculator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.objectlab.kit.datecalc.common.KitCalculatorsFactory
getDateCalculator, getIMMDateCalculator, getPeriodCountCalculator
 

Constructor Detail

AbstractKitCalculatorsFactory

public AbstractKitCalculatorsFactory()
Method Detail

registerHolidays

@Deprecated
public void registerHolidays(java.lang.String name,
                                        java.util.Set<E> holidaysSet)
Deprecated. use the HolidayCalendar

Use this method to register a set of holidays for a given calendar, it will replace any existing set. It won't update any existing DateCalculator as these should not be amended whilst in existence (we could otherwise get inconsistent results).

Specified by:
registerHolidays in interface KitCalculatorsFactory<E>
Parameters:
name - the calendar name to register these holidays under.
holidaysSet - the set of holidays (non-working days).

registerHolidays

public void registerHolidays(java.lang.String name,
                             HolidayCalendar<E> holidaysCalendar)
Use this method to register a given calendar, it will replace any existing one with the same name. An immutable copy is made so that any changes outside this class will have no affect. It won't update any existing DateCalculator as these should not be amended whilst in existence (we could otherwise get inconsistent results).

Specified by:
registerHolidays in interface KitCalculatorsFactory<E>
Parameters:
name - the calendar name to register these holidays under.
holidaysSet - the set of holidays (non-working days).

isHolidayCalendarRegistered

public boolean isHolidayCalendarRegistered(java.lang.String name)
Specified by:
isHolidayCalendarRegistered in interface KitCalculatorsFactory<E>
Returns:
true if the holiday name is registered.

getHolidayCalendar

public HolidayCalendar<E> getHolidayCalendar(java.lang.String name)
Specified by:
getHolidayCalendar in interface KitCalculatorsFactory<E>
Returns:
an immutable Holiday Calendar that is registered, null if not registered.

setHolidays

protected void setHolidays(java.lang.String name,
                           DateCalculator<E> dc)
Used by extensions to set holidays in a DateCalculator.

Parameters:
name - holiday name
dc - the date calculator to configure.