private static RateCalculation parseInflationRateCalculation(CsvRow row, String leg, PriceIndex priceIndex, Currency currency) { InflationRateCalculation.Builder builder = InflationRateCalculation.builder(); // basics builder.index(priceIndex); builder.lag(parseInflationLag(findValue(row, leg, INFLATION_LAG_FIELD), currency)); builder.indexCalculationMethod(parseInflationMethod(findValue(row, leg, INFLATION_METHOD_FIELD), currency)); // optionals findValue(row, leg, INFLATION_FIRST_INDEX_VALUE_FIELD) .map(s -> LoaderUtils.parseDouble(s)) .ifPresent(v -> builder.firstIndexValue(v)); findValue(row, leg, GEARING_FIELD) .map(s -> LoaderUtils.parseDouble(s)) .ifPresent(v -> builder.gearing(ValueSchedule.of(v))); return builder.build(); }
public void test_builder() { InflationRateCalculation test1 = InflationRateCalculation.builder() .index(CH_CPI) .lag(Period.ofMonths(3)) .indexCalculationMethod(MONTHLY) .firstIndexValue(123d) .build(); assertEquals(test1.getIndex(), CH_CPI); assertEquals(test1.getLag(), Period.ofMonths(3)); assertEquals(test1.getIndexCalculationMethod(), MONTHLY); assertEquals(test1.getGearing(), Optional.empty()); assertEquals(test1.getFirstIndexValue(), OptionalDouble.of(123d)); assertEquals(test1.getType(), SwapLegType.INFLATION); InflationRateCalculation test2 = InflationRateCalculation.builder() .index(GB_HICP) .lag(Period.ofMonths(4)) .indexCalculationMethod(INTERPOLATED) .gearing(GEARING) .build(); assertEquals(test2.getIndex(), GB_HICP); assertEquals(test2.getLag(), Period.ofMonths(4)); assertEquals(test2.getIndexCalculationMethod(), INTERPOLATED); assertEquals(test2.getFirstIndexValue(), OptionalDouble.empty()); assertEquals(test2.getGearing().get(), GEARING); assertEquals(test2.getType(), SwapLegType.INFLATION); }
builder.gearing(parseSchedule(el, document)); }); return builder.build();
public void coverage() { InflationRateCalculation test1 = InflationRateCalculation.builder() .index(CH_CPI) .lag(Period.ofMonths(3)) .indexCalculationMethod(MONTHLY) .build(); coverImmutableBean(test1); InflationRateCalculation test2 = InflationRateCalculation.builder() .index(GB_HICP) .lag(Period.ofMonths(4)) .indexCalculationMethod(INTERPOLATED) .gearing(GEARING) .build(); coverBeanEquals(test1, test2); }