ForexOptionDigitalDefinition implements InstrumentDefinition<InstrumentDerivative> { @Override public ForexOptionDigital toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); final Forex fx = _underlyingForex.toDerivative(date); final double expirationTime = TimeCalculator.getTimeBetween(date, _expirationDate); return new ForexOptionDigital(fx, expirationTime, _isCall, _isLong, _payDomestic); } ForexOptionDigitalDefinition(final ForexDefinition forex, final ZonedDateTime expirationDate, final boolean isCall, final boolean isLong);  ForexOptionDigitalDefinition(final ForexDefinition forex, final ZonedDateTime expirationDate, final boolean isCall, final boolean isLong, final boolean payDomestic); ForexDefinition getUnderlyingForex(); ZonedDateTime getExpirationDate(); boolean isCall(); boolean isLong(); boolean payDomestic(); @Override ForexOptionDigital 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 toDerivative() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20); final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate); final Forex fx = FX_DEFINITION.toDerivative(referenceDate); final DayCount actAct = DayCounts.ACT_ACT_ISDA; final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE); final ForexOptionDigital optionConstructed = new ForexOptionDigital(fx, expirationTime, IS_CALL, IS_LONG, PAY_DOM); assertEquals("Convertion to derivative", optionConstructed, optionConverted); }