/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Iterator i = subtractions.iterator(); i.hasNext();) { final Period subtraction = (Period) i.next(); for (final Iterator j = result.iterator(); j.hasNext();) { final Period period = (Period) j.next(); tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
suite.addTest(new PeriodListTest("testIsEmpty", firstHalf.subtract(year1994))); suite.addTest(new PeriodListTest("testIsEmpty", winter.subtract(winter))); suite.addTest(new PeriodListTest("testContains", winter.subtract(spring), winter)); suite.addTest(new PeriodListTest(winter.subtract(spring), 1)); PeriodList aprToMay = marchToMay.subtract(marchToApril); suite.addTest(new PeriodListTest(aprToMay, 1)); suite.addTest(new PeriodListTest(year1994.subtract(monthApril), 2));