/// <summary> /// Resolves this adjustment using the specified reference data, returning an adjuster. /// <para> /// This returns a <seealso cref="DateAdjuster"/> that performs the same calculation as this adjustment. /// It binds the holiday calendar, looked up from the reference data, into the result. /// As such, there is no need to pass the reference data in again. /// </para> /// <para> /// The resulting adjuster will be <seealso cref="#normalized() normalized"/>. /// /// </para> /// </summary> /// <param name="refData"> the reference data, used to find the holiday calendar </param> /// <returns> the adjuster, bound to a specific holiday calendar </returns> public DateAdjuster resolve(ReferenceData refData) { HolidayCalendar holCalAdj = adjustment.Calendar.resolve(refData); if (calendar == HolidayCalendarIds.NO_HOLIDAYS) { BusinessDayConvention adjustmentConvention = adjustment.Convention; return(date => adjustmentConvention.adjust(LocalDateUtils.plusDays(date, days), holCalAdj)); } HolidayCalendar holCalAdd = calendar.resolve(refData); BusinessDayConvention adjustmentConvention = adjustment.Convention; return(date => adjustmentConvention.adjust(holCalAdd.shift(date, days), holCalAdj)); }
public LocalDate calculateEffectiveFromFixing(LocalDate fixingDate, ReferenceData refData) { HolidayCalendar fixingCal = fixingCalendar.resolve(refData); return(fixingCal.shift(fixingCal.nextOrSame(fixingDate), effectiveDateOffset)); }
public LocalDate calculateMaturityFromEffective(LocalDate effectiveDate, ReferenceData refData) { HolidayCalendar fixingCal = fixingCalendar.resolve(refData); return(fixingCal.shift(fixingCal.nextOrSame(effectiveDate), 1)); }
private void assertSatSun(HolidayCalendar test) { assertEquals(test.shift(THU_2014_07_10, 2), MON_2014_07_14); assertEquals(test.shift(FRI_2014_07_11, 2), TUE_2014_07_15); assertEquals(test.shift(SUN_2014_07_13, 2), TUE_2014_07_15); assertEquals(test.shift(MON_2014_07_14, 2), WED_2014_07_16); assertEquals(test.shift(FRI_2014_07_11, -2), WED_2014_07_09); assertEquals(test.shift(SAT_2014_07_12, -2), THU_2014_07_10); assertEquals(test.shift(SUN_2014_07_13, -2), THU_2014_07_10); assertEquals(test.shift(MON_2014_07_14, -2), THU_2014_07_10); assertEquals(test.shift(TUE_2014_07_15, -2), FRI_2014_07_11); assertEquals(test.shift(WED_2014_07_16, -2), MON_2014_07_14); assertEquals(test.shift(FRI_2014_07_11, 5), FRI_2014_07_18); assertEquals(test.shift(FRI_2014_07_11, 6), MON_2014_07_21); assertEquals(test.shift(FRI_2014_07_18, -5), FRI_2014_07_11); assertEquals(test.shift(MON_2014_07_21, -6), FRI_2014_07_11); assertEquals(test.shift(SAT_2014_07_12, 5), FRI_2014_07_18); assertEquals(test.shift(SAT_2014_07_12, -5), MON_2014_07_07); }