ForexDefinition implements InstrumentDefinition<InstrumentDerivative> { @Override public Forex toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); final PaymentFixed payment1 = _paymentCurrency1.toDerivative(date); final PaymentFixed payment2 = _paymentCurrency2.toDerivative(date); return new Forex(payment1, payment2); } ForexDefinition(final Currency currency1, final Currency currency2, final ZonedDateTime exchangeDate, final double amountCurrency1, final double fxRate);  ForexDefinition(final PaymentFixedDefinition paymentCurrency1, final PaymentFixedDefinition paymentCurrency2); static ForexDefinition fromAmounts(final Currency currency1, final Currency currency2, final ZonedDateTime exchangeDate, final double amountCurrency1,
      final double amountCurrency2); PaymentFixedDefinition getPaymentCurrency1(); PaymentFixedDefinition getPaymentCurrency2(); Currency getCurrency1(); Currency getCurrency2(); ZonedDateTime getExchangeDate(); @Override Forex toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void toDerivative() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20); final Forex fxConverted = FX.toDerivative(referenceDate); final PaymentFixed pay1 = PAY_1.toDerivative(referenceDate); final PaymentFixed pay2 = PAY_2.toDerivative(referenceDate); final Forex fxComparison = new Forex(pay1, pay2); assertEquals(fxComparison, fxConverted); }