SwaptionBermudaFixedIborDefinition implements InstrumentDefinition<SwaptionBermudaFixedIbor> { public static SwaptionBermudaFixedIborDefinition from(final SwapFixedIborDefinition underlyingTotalSwap, final boolean isLong, final ZonedDateTime[] expiryDate) { ArgumentChecker.notNull(expiryDate, "expiry date"); ArgumentChecker.notNull(underlyingTotalSwap, "underlying swap"); final int nbExpiry = underlyingTotalSwap.getFixedLeg().getNumberOfPayments(); ArgumentChecker.isTrue(expiryDate.length == nbExpiry, "Number of expiries provided {} did not match the number of fixed payments of underlying swap {}", expiryDate.length, nbExpiry); final SwapFixedIborDefinition[] underlyingSwaps = new SwapFixedIborDefinition[nbExpiry]; for (int loopexp = 0; loopexp < nbExpiry; loopexp++) { underlyingSwaps[loopexp] = underlyingTotalSwap.trimStart(expiryDate[loopexp]); } return new SwaptionBermudaFixedIborDefinition(underlyingSwaps, isLong, expiryDate); } SwaptionBermudaFixedIborDefinition(final SwapFixedIborDefinition[] underlyingSwap, final boolean isLong, final ZonedDateTime[] expiryDate); static SwaptionBermudaFixedIborDefinition from(final SwapFixedIborDefinition underlyingTotalSwap, final boolean isLong, final ZonedDateTime[] expiryDate); SwapFixedIborDefinition[] getUnderlyingSwap(); boolean isLong(); ZonedDateTime[] getExpiryDate(); @Override SwaptionBermudaFixedIbor 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 from() { final SwaptionBermudaFixedIborDefinition bermuda2 = SwaptionBermudaFixedIborDefinition.from(TOTAL_SWAP_DEFINITION, IS_LONG, EXPIRY_DATE); assertEquals("Bermuda swaption builder", BERMUDA_SWAPTION_DEFINITION, bermuda2); }