SwaptionBermudaFixedIborDefinition implements InstrumentDefinition<SwaptionBermudaFixedIbor> { @Override public SwaptionBermudaFixedIbor toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); final int nbExpiry = _expiryDate.length; final double[] expiryTime = new double[nbExpiry]; final double[] settleTime = new double[nbExpiry]; @SuppressWarnings("unchecked") final SwapFixedCoupon<Coupon>[] expirySwap = new SwapFixedCoupon[nbExpiry]; for (int loopexp = 0; loopexp < nbExpiry; loopexp++) { expiryTime[loopexp] = TimeCalculator.getTimeBetween(date, _expiryDate[loopexp]); expirySwap[loopexp] = _underlyingSwap[loopexp].toDerivative(date); settleTime[loopexp] = TimeCalculator.getTimeBetween(date, _underlyingSwap[loopexp].getFixedLeg().getNthPayment(0).getAccrualStartDate()); } return new SwaptionBermudaFixedIbor(expirySwap, _isLong, expiryTime, settleTime); } SwaptionBermudaFixedIborDefinition(final SwapFixedIborDefinition[] underlyingSwap, final boolean isLong, final ZonedDateTime[] expiryDate); static SwaptionBermudaFixedIborDefinition from(final SwapFixedIborDefinition underlyingTotalSwap, final boolean isLong, final ZonedDateTime[] expiryDate); SwapFixedIborDefinition[] getUnderlyingSwap(); boolean isLong(); ZonedDateTime[] getExpiryDate(); @Override SwaptionBermudaFixedIbor toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void toDerivatives() { final DayCount actAct = DayCounts.ACT_ACT_ISDA; final double[] expiryTime = new double[NB_EXPIRY]; final double[] settleTime = new double[NB_EXPIRY]; @SuppressWarnings("unchecked") final SwapFixedCoupon<Coupon>[] underlyingSwap = new SwapFixedCoupon[NB_EXPIRY]; for (int loopexp = 0; loopexp < NB_EXPIRY; loopexp++) { expiryTime[loopexp] = actAct.getDayCountFraction(REFERENCE_DATE, EXPIRY_DATE[loopexp]); underlyingSwap[loopexp] = EXPIRY_SWAP_DEFINITION[loopexp].toDerivative(REFERENCE_DATE); settleTime[loopexp] = actAct.getDayCountFraction(REFERENCE_DATE, EXPIRY_SWAP_DEFINITION[loopexp].getFixedLeg().getNthPayment(0).getAccrualStartDate()); } final SwaptionBermudaFixedIbor swaptionBermuda = new SwaptionBermudaFixedIbor(underlyingSwap, IS_LONG, expiryTime, settleTime); assertEquals("Swaption Bermuda: to derivatives", swaptionBermuda, BERMUDA_SWAPTION_DEFINITION.toDerivative(REFERENCE_DATE)); }