|
From: <ma...@us...> - 2006-08-26 09:04:56
|
Revision: 58 Author: marchy Date: 2006-08-26 02:04:48 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/objectlabkit/?rev=58&view=rev Log Message: ----------- Added licence, and javadoc Modified Paths: -------------- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculator.java Modified: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculator.java =================================================================== --- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculator.java 2006-08-26 08:44:37 UTC (rev 57) +++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculator.java 2006-08-26 09:04:48 UTC (rev 58) @@ -1,3 +1,20 @@ +/* + * $Id$ + * + * Copyright 2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package net.objectlab.kit.datecalc.common; import java.util.Collections; @@ -4,6 +21,18 @@ import java.util.HashSet; import java.util.Set; +/** + * Abstract implementation in order to encapsulate all the common functionality + * between Jdk and Joda implementations. It is parametrized on <code><E></code> + * but basically <code>Date</code> and <code>LocalDate</code> are the only + * viable values for it for now. + * + * @author Marcin Jekot + * @author $LastChangedBy$ + * @version $Revision$ $Date$ + * + * @param <E> + */ public abstract class AbstractDateCalculator<E> implements DateCalculator<E> { protected static final int MONTHS_IN_QUARTER = 3; @@ -22,7 +51,8 @@ private HolidayHandler<E> holidayHandler; - protected AbstractDateCalculator(final String name, final Set<E> nonWorkingDays, final HolidayHandler<E> holidayHandler) { + protected AbstractDateCalculator(final String name, + final Set<E> nonWorkingDays, final HolidayHandler<E> holidayHandler) { this.name = name; this.nonWorkingDays = nonWorkingDays; this.holidayHandler = holidayHandler; @@ -149,9 +179,13 @@ return this; } - if (holidayHandler == null && calendar.getHolidayHandlerType() != null || holidayHandler != null - && !holidayHandler.getType().equals(calendar.getHolidayHandlerType())) { - throw new IllegalArgumentException("Combined Calendars cannot have different handler types"); + if (holidayHandler == null + && calendar.getHolidayHandlerType() != null + || holidayHandler != null + && !holidayHandler.getType().equals( + calendar.getHolidayHandlerType())) { + throw new IllegalArgumentException( + "Combined Calendars cannot have different handler types"); } final Set<E> newSet = new HashSet<E>(); @@ -162,8 +196,8 @@ newSet.addAll(calendar.getNonWorkingDays()); } - final DateCalculator<E> cal = createNewCalcultaor(getName() + "/" + calendar.getName(), getStartDate(), newSet, - holidayHandler); + final DateCalculator<E> cal = createNewCalcultaor(getName() + "/" + + calendar.getName(), getStartDate(), newSet, holidayHandler); return cal; } @@ -182,8 +216,9 @@ return getNextIMMDate(false, currentBusinessDate); } - protected abstract E getNextIMMDate(final boolean forward, final E theStartDate); + protected abstract E getNextIMMDate(final boolean forward, + final E theStartDate); - protected abstract DateCalculator<E> createNewCalcultaor(String calcName, E theStartDate, Set<E> holidays, - HolidayHandler<E> handler); + protected abstract DateCalculator<E> createNewCalcultaor(String calcName, + E theStartDate, Set<E> holidays, HolidayHandler<E> handler); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |