SwaptionCashFixedIborDefinition implements InstrumentDefinition<SwaptionCashFixedIbor> { @Override public SwaptionCashFixedIbor toDerivative(final ZonedDateTime dateTime) { ArgumentChecker.notNull(dateTime, "date"); final LocalDate dayConversion = dateTime.toLocalDate(); ArgumentChecker.isTrue(!dayConversion.isAfter(getExpiry().getExpiry().toLocalDate()), "date is after expiry date"); final double expiryTime = TimeCalculator.getTimeBetween(dateTime, _expiry.getExpiry()); final double settlementTime = TimeCalculator.getTimeBetween(dateTime, _settlementDate); final SwapFixedCoupon<? extends Payment> underlyingSwap = _underlyingSwap.toDerivative(dateTime); return SwaptionCashFixedIbor.from(expiryTime, underlyingSwap, settlementTime, _isCall, _isLong); } private  SwaptionCashFixedIborDefinition(final ZonedDateTime expiryDate, final SwapFixedIborDefinition underlyingSwap, final boolean isCall, final boolean isLong); @Deprecated static SwaptionCashFixedIborDefinition from(final ZonedDateTime expiryDate, final SwapFixedIborDefinition underlyingSwap, final boolean isLong); static SwaptionCashFixedIborDefinition from(final ZonedDateTime expiryDate, final SwapFixedIborDefinition underlyingSwap, final boolean isCall, final boolean isLong); @Override SwaptionCashFixedIbor toDerivative(final ZonedDateTime dateTime); SwapFixedIborDefinition getUnderlyingSwap(); boolean isLong(); boolean isCall(); ZonedDateTime getSettlementDate(); Expiry getExpiry(); Currency getCurrency(); @Override String toString(); @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 testToDerivative() { final DayCount actAct = DayCounts.ACT_ACT_ISDA; final ZonedDateTime zonedDate = ZonedDateTime.of(LocalDateTime.of(REFERENCE_DATE.toLocalDate(), LocalTime.MIDNIGHT), ZoneOffset.UTC); final double expiryTime = actAct.getDayCountFraction(zonedDate, EXPIRY_DATE); SwaptionCashFixedIbor convertedSwaption = SWAPTION_DEPRECATED.toDerivative(REFERENCE_DATE); assertEquals(expiryTime, convertedSwaption.getTimeToExpiry(), 1E-10); assertEquals(SWAPTION_DEPRECATED.getUnderlyingSwap().toDerivative(REFERENCE_DATE), convertedSwaption.getUnderlyingSwap()); convertedSwaption = SWAPTION.toDerivative(REFERENCE_DATE); assertEquals(expiryTime, convertedSwaption.getTimeToExpiry(), 1E-10); assertEquals(SWAPTION.getUnderlyingSwap().toDerivative(REFERENCE_DATE), convertedSwaption.getUnderlyingSwap()); }