AggregationUtils implements Serializable { @SuppressWarnings("unchecked") public static <T extends Number, I extends Number> Double multiply(T m1, I m2){ if(m1 == null || m2 == null){ return null; } return m1.doubleValue() * m2.doubleValue(); } private  AggregationUtils(); @SuppressWarnings("unchecked") // both types are the same and extends from Comparable static int compare(T o1, I o2); @SuppressWarnings("unchecked") // manually checked type security static Double add(T o1, I o2); @SuppressWarnings("unchecked") // manually checked type security static Double subtract(T o1, I o2); @SuppressWarnings("unchecked") // manually checked type security static Double multiply(T m1, I m2); @SuppressWarnings("unchecked") // manually checked type security static Double divide(T divided, I divider);  }
@Test public void multiply() { assertEquals(100, AggregationUtils.multiply(10, 10), delta); assertEquals(100, AggregationUtils.multiply(10L, 10F), delta); assertEquals(100, AggregationUtils.multiply(10F, 10D), delta); assertEquals(100, AggregationUtils.multiply(10D, 10L), delta); }