HolidayCalendar API changing in upcoming beta

Submitted by morgdx on Thu, 2007-01-04 16:03.

The upcoming beta of the DateMath library (0.2.0) will make changes to the implementation of HolidayCalendar and HolidayCalendarFactory which will break previous custom implementations of these which you may be using.

As work has progressed on the first release of the trade module, it has become clear that Generics need to be used more widely to retain strong typing of subclasses of Period (for example if you want the ScheduleGenerator and HolidayCalendars to operate seemlessly on a custom AccrualPeriod class which extends Period).

To this end, a new Generics ScheduleGenerator is being introduced which, as well as supporting subclasses of Period in a type safe manner, vastly simplifies the existing implementation.

There have also been changes made to the HolidayCalendar and HolidayCalendarFactory classes which will happily coexist with legacy client code based upon the old API, now additionally supports creation of Generic HolidayCalendars, but requires that any implementations of HolidayCalendar and HolidayCalendarFactory must be changed.

The change to any implementations of HolidayCalendar is trivial;

Change:

public class MyHolidayCalendar extends HolidayCalendar

To:

public class MyHolidayCalendar<T> extends HolidayCalendar

The change to HolidayCalendarFactory implementations, however, is slightly more involved. The abstract HolidayCalendarFactory class now contains an additional abstract method:

public abstract <T extends Period> HolidayCalendar<T> getHolidayCalendar(String locale, Class<T> c);

The easiest way to update your current implementation is to change the signature of your current getHolidayCalendar method to match this one (ensuring that when you construct new HolidayCalendars they are generically typed to HolidayCalendar<T>) and then make this called by:

public HolidayCalendar getHolidayCalendar(String locale) {
 return getHolidayCalendar(locale, Period.class);
}

If you need any pointers, please contact me or look at how the implementation has changed of org.jfin.date.holiday.defaultimpl.

If you have any comments on this then please leave them below, or create a new topic in the forums.

Vote Result
Score: 0.0, Votes: 0
email this story

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
More information about formatting options Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.