PaymentFixedDefinition extends PaymentDefinition { @Override public PaymentFixed toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date {} is after payment date {}", date, getPaymentDate()); final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate()); return new PaymentFixed(getCurrency(), paymentTime, _amount); } PaymentFixedDefinition(final Currency currency, final ZonedDateTime paymentDate, final double amount); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override PaymentFixed toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override double getReferenceAmount();  }
@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 paymentTime = actAct.getDayCountFraction(zonedDate, PAYMENT_DATE); final PaymentFixed paymentFixed = new PaymentFixed(CUR, paymentTime, AMOUNT); final PaymentFixed convertedDefinition = FIXED_PAYMENT.toDerivative(REFERENCE_DATE); assertEquals(paymentFixed, convertedDefinition); }