Beispiel #1
0
 private boolean isEnclosedByAHolidayWithRepaymentRule(DateTime date, RepaymentRuleTypes rule) {
   for (Holiday holiday : this.upcomingHolidays) {
     if (holiday.encloses(date.toDate()) && (holiday.getRepaymentRuleType() == rule)) {
       return true;
     }
   }
   return false;
 }
Beispiel #2
0
 private boolean isEnclosedByAHoliday(DateTime date) {
   for (Holiday holiday : this.upcomingHolidays) {
     if (holiday.encloses(date.toDate())) {
       return true;
     }
   }
   return false;
 }
Beispiel #3
0
 private int countDatesEnclosedByHoliday(List<DateTime> dates, Holiday holiday) {
   int countEnclosedDates = 0;
   for (int i = 0; i < dates.size(); i++) {
     if (holiday.encloses(dates.get(i).toDate())) {
       countEnclosedDates++;
     }
   }
   return countEnclosedDates;
 }
Beispiel #4
0
  private Holiday getHolidayEnclosing(DateTime date) {

    assert isEnclosedByAHoliday(date);

    Holiday holidayEnclosingDate = null;
    for (Holiday holiday : upcomingHolidays) {
      if (holiday.encloses(date.toDate())) {
        holidayEnclosingDate = holiday;
      }
    }
    return holidayEnclosingDate;
  }
Beispiel #5
0
  /**
   * Given that the first date in the list falls in a non-Moratorium holiday, return the list of
   * dates that fall in the holiday, but shifted out of the holiday using the holiday's repayment
   * rule. TODO keithp: once dates are shifted past all non-moratorium holidays, then check whether
   * any fall in a moratorium period. If they do, push them past the moratorium, but do not push out
   * future dates. TODO keithp: if shifting a date does not change the date (e.g. same day holiday),
   * then we're done with it, so move to the next date.
   */
  private List<DateTime> shiftDatesInNonMoratoriumHoliday(List<DateTime> dates) {

    assert dates != null;
    assert !dates.isEmpty();
    assert isEnclosedByAHoliday(dates.get(0));
    assert !isEnclosedByAHolidayWithRepaymentRule(
        dates.get(0), RepaymentRuleTypes.REPAYMENT_MORATORIUM);

    Holiday enclosingHoliday = getHolidayEnclosing(dates.get(0));
    List<DateTime> shiftedDatesInHoliday = new ArrayList<DateTime>();
    for (int i = 0; i < dates.size(); i++) {
      if (enclosingHoliday.encloses(dates.get(i).toDate())) {
        shiftedDatesInHoliday.add(nonMoratoriumAdjustmentStrategy.adjust(dates.get(i)));
      }
    }
    return shiftedDatesInHoliday;
  }