MetalFutureOptionDefinition extends CommodityFutureOptionDefinition<MetalFutureDefinition, MetalFutureOption> { @Override public MetalFutureOption toDerivative(final ZonedDateTime date) { ArgumentChecker.inOrderOrEqual(date, this.getExpiryDate(), "date", "expiry date"); final double timeToFixing = TimeCalculator.getTimeBetween(date, this.getExpiryDate()); return new MetalFutureOption(timeToFixing, getUnderlying().toDerivative(date), getStrike(), getExerciseType(), isCall()); } MetalFutureOptionDefinition(final ZonedDateTime expiryDate, final MetalFutureDefinition underlying, final double strike, final ExerciseDecisionType exerciseType,
      final boolean isCall); @Override MetalFutureOption 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 testToDerivative() { MetalFutureOptionDefinition first = new MetalFutureOptionDefinition(EXPIRY_DATE, AN_UNDERLYING, 100, ExerciseDecisionType.EUROPEAN, true); MetalFutureOptionDefinition second = new MetalFutureOptionDefinition(EXPIRY_DATE, AN_UNDERLYING, 100, ExerciseDecisionType.AMERICAN, false); MetalFutureOption firstDerivative = first.toDerivative(A_DATE); MetalFutureOption secondDerivative = second.toDerivative(A_DATE); assertEquals(firstDerivative.getStrike(), 100.); assertEquals(firstDerivative.getExerciseType(), ExerciseDecisionType.EUROPEAN); assertEquals(firstDerivative.getUnderlying(), AN_UNDERLYING.toDerivative(A_DATE)); assertTrue(firstDerivative.isCall()); assertEquals(secondDerivative.getExerciseType(), ExerciseDecisionType.AMERICAN); assertFalse(secondDerivative.isCall()); MetalFutureOption firstDerivative2 = new MetalFutureOption(0.0027397260273972603, AN_UNDERLYING.toDerivative(A_DATE), 100, ExerciseDecisionType.EUROPEAN, true); assertEquals(firstDerivative.hashCode(), firstDerivative2.hashCode()); assertEquals(firstDerivative, firstDerivative2); }