Source:
<code>public ImmutableList<RateAccrualPeriod> createAccrualPeriods( Schedule accrualSchedule, Schedule paymentSchedule, ReferenceData refData) { DoubleArray resolvedGearings = firstNonNull(gearing, ALWAYS_1).resolveValues(accrualSchedule); DoubleArray resolvedSpreads = firstNonNull(spread, ALWAYS_0).resolveValues(accrualSchedule); DateAdjuster fixingDateAdjuster = fixingDateOffset.resolve(refData); Function<SchedulePeriod, Schedule> resetScheduleFn = <START> getResetPeriods().map(rp -> getIndex().getCurrency().equals(CNY) && rp.getResetFrequency().equals(P1W) ? <END> rp.createSchedule(RollConventions.NONE, refData) : rp.createSchedule(accrualSchedule.getRollConvention(), refData)).orElse(null); Function<LocalDate, IborIndexObservation> iborObservationFn = index.resolve(refData); Optional<SchedulePeriod> scheduleInitialStub = accrualSchedule.getInitialStub(); Optional<SchedulePeriod> scheduleFinalStub = accrualSchedule.getFinalStub(); ImmutableList.Builder<RateAccrualPeriod> accrualPeriods = ImmutableList.builder(); for (int i = 0; i < accrualSchedule.size(); i++) { SchedulePeriod period = accrualSchedule.getPeriod(i); RateComputation rateComputation = createRateComputation( period, fixingDateAdjuster, resetScheduleFn, iborObservationFn, i, scheduleInitialStub, scheduleFinalStub, refData); double yearFraction = period.yearFraction(dayCount, accrualSchedule); accrualPeriods.add(new RateAccrualPeriod( period, yearFraction, rateComputation, resolvedGearings.get(i), resolvedSpreads.get(i), negativeRateMethod)); } return accrualPeriods.build(); }</code><technical_language>I more general here. If accrualSchedule.getFrequency().isMonthBased() rp.getResetFrequency().isWeekBased() then..</technical_language>

Target:
public ImmutableList<RateAccrualPeriod> createAccrualPeriods( Schedule accrualSchedule, Schedule paymentSchedule, ReferenceData refData) { DoubleArray resolvedGearings = firstNonNull(gearing, ALWAYS_1).resolveValues(accrualSchedule); DoubleArray resolvedSpreads = firstNonNull(spread, ALWAYS_0).resolveValues(accrualSchedule); DateAdjuster fixingDateAdjuster = fixingDateOffset.resolve(refData); Function<SchedulePeriod, Schedule> resetScheduleFn = getResetPeriods().map(rp -> accrualSchedule.getFrequency().isMonthBased() && rp.getResetFrequency().isWeekBased() ? rp.createSchedule(RollConventions.NONE, refData) : rp.createSchedule(accrualSchedule.getRollConvention(), refData)) .orElse(null); Function<LocalDate, IborIndexObservation> iborObservationFn = index.resolve(refData); Optional<SchedulePeriod> scheduleInitialStub = accrualSchedule.getInitialStub(); Optional<SchedulePeriod> scheduleFinalStub = accrualSchedule.getFinalStub(); ImmutableList.Builder<RateAccrualPeriod> accrualPeriods = ImmutableList.builder(); for (int i = 0; i < accrualSchedule.size(); i++) { SchedulePeriod period = accrualSchedule.getPeriod(i); RateComputation rateComputation = createRateComputation( period, fixingDateAdjuster, resetScheduleFn, iborObservationFn, i, scheduleInitialStub, scheduleFinalStub, refData); double yearFraction = period.yearFraction(dayCount, accrualSchedule); accrualPeriods.add(new RateAccrualPeriod( period, yearFraction, rateComputation, resolvedGearings.get(i), resolvedSpreads.get(i), negativeRateMethod)); } return accrualPeriods.build(); }