final FloatingInterestRateLeg legFloat = (FloatingInterestRateLeg) swapLeg[loopleg];
final ConventionBundle iborIndexConvention = _conventionSource.getConventionBundle(legFloat.getFloatingReferenceRateId());
if (iborIndexConvention == null) {
throw new OpenGammaRuntimeException("Could not get Ibor index convention for " + currency[0] + " using " + legFloat.getFloatingReferenceRateId());
}
final Period tenorIbor = iborIndexConvention.getPeriod();
final IborIndex iborIndex = new IborIndex(currency[loopleg], tenorIbor, iborIndexConvention.getSettlementDays(), iborIndexConvention.getDayCount(),
iborIndexConvention.getBusinessDayConvention(), iborIndexConvention.isEOMConvention());
legDefinition.add(AnnuityDefinitionBuilder.annuityIborSpreadWithNotionalFrom(settlementDate, maturityDate, notional[loopleg], iborIndex, spread, payer[loopleg], calendar[loopleg]));
} else {
if (swapLeg[loopleg] instanceof FixedInterestRateLeg) { // Leg is Fixed
final FixedInterestRateLeg legFixed = (FixedInterestRateLeg) swapLeg[loopleg];
final BusinessDayConvention businessDay = legFixed.getBusinessDayConvention();
if (businessDay == null) {
throw new OpenGammaRuntimeException("Could not get Business Day for " + legFixed);
}
final boolean isEOM = legFixed.isEom();
final Frequency freqFixed = legFixed.getFrequency();
final Period tenorFixed = getTenor(freqFixed);
legDefinition.add(AnnuityDefinitionBuilder.annuityCouponFixedWithNotional(currency[loopleg], settlementDate, maturityDate, tenorFixed,
calendar[loopleg], legFixed.getDayCount(), businessDay, isEOM, notional[loopleg], legFixed.getRate(), payer[loopleg]));
} else {
throw new OpenGammaRuntimeException("X Ccy Swap legs should be Fixed or Floating legs");
}