TaylorExpansionMultiplierCalculator { public static double getMultiplier(final Underlying underlying) { Validate.notNull(underlying, "underlying"); if (underlying instanceof NthOrderUnderlying) { final NthOrderUnderlying nthOrder = (NthOrderUnderlying) underlying; final int n = nthOrder.getOrder(); if (n == 0) { return 1; } return 1. / MathUtils.factorial(n); } else if (underlying instanceof MixedOrderUnderlying) { final MixedOrderUnderlying mixedOrder = (MixedOrderUnderlying) underlying; double result = 1; for (final NthOrderUnderlying underlyingOrder : mixedOrder.getUnderlyingOrders()) { result *= getMultiplier(underlyingOrder); } return result; } throw new IllegalArgumentException("Order was neither NthOrderUnderlying nor MixedOrderUnderlying: have " + underlying.getClass()); }  static double getMultiplier(final Underlying underlying); static double getValue(final Map<UnderlyingType, Double> underlyingData, final Underlying underlying); static DoubleTimeSeries<?> getTimeSeries(final Map<UnderlyingType, DoubleTimeSeries<?>> underlyingData, final Underlying underlying);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullOrder1() { getMultiplier(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testUnderlyingType1() { getMultiplier(NEW_TYPE); }