@Test public void testAddLongWithLongOutput() { Assert.assertEquals(new Long(20), Arith.add(new Long(10), new Long(10), IntegerType.TYPE)); }
public static Object add(Object operand1, Object operand2, Type resultType) { Object o1 = resultType.cast(operand1); Object o2 = resultType.cast(operand2); Object result; if (resultType instanceof BigDecimalType) { result = ((BigDecimal) o1).add((BigDecimal) o2); } else if (resultType instanceof BigIntegerType) { result = ((BigInteger) o1).add((BigInteger) o2); } else if (resultType instanceof DoubleType) { result = ((Double) o1).doubleValue() + ((Double) o2).doubleValue(); } else { result = ((Long) o1).longValue() + ((Long) o2).longValue(); } return result; }
Arith { public static Object add(Object operand1, Object operand2, Type resultType) { Object o1 = resultType.cast(operand1); Object o2 = resultType.cast(operand2); Object result; if (resultType instanceof BigDecimalType) { result = ((BigDecimal) o1).add((BigDecimal) o2); } else if (resultType instanceof BigIntegerType) { result = ((BigInteger) o1).add((BigInteger) o2); } else if (resultType instanceof DoubleType) { result = ((Double) o1).doubleValue() + ((Double) o2).doubleValue(); } else { result = ((Long) o1).longValue() + ((Long) o2).longValue(); } return result; } }
Arith { public static Object add(Object operand1, Object operand2, Type resultType) { Object o1 = resultType.cast(operand1); Object o2 = resultType.cast(operand2); Object result; if (resultType instanceof BigDecimalType) { result = ((BigDecimal) o1).add((BigDecimal) o2); } else if (resultType instanceof BigIntegerType) { result = ((BigInteger) o1).add((BigInteger) o2); } else if (resultType instanceof DoubleType) { result = ((Double) o1).doubleValue() + ((Double) o2).doubleValue(); } else { result = ((Long) o1).longValue() + ((Long) o2).longValue(); } return result; } private  Arith(); }
Arith { public static Object add(Object operand1, Object operand2, Type resultType) { Object o1 = resultType.cast(operand1); Object o2 = resultType.cast(operand2); Object result; if (resultType instanceof BigDecimalType) { result = ((BigDecimal) o1).add((BigDecimal) o2); } else if (resultType instanceof BigIntegerType) { result = ((BigInteger) o1).add((BigInteger) o2); } else if (resultType instanceof DoubleType) { result = ((Double) o1).doubleValue() + ((Double) o2).doubleValue(); } else { result = ((Long) o1).longValue() + ((Long) o2).longValue(); } return result; } private  Arith(); static Object add(Object operand1,
                             Object operand2,
                             Type resultType); static Type promote(Type operand1,
                               Type operand2); }
Arith { public static Object add(Object operand1, Object operand2, Type resultType) { Object o1 = resultType.cast(operand1); Object o2 = resultType.cast(operand2); Object result; if (resultType instanceof BigDecimalType) { result = ((BigDecimal) o1).add((BigDecimal) o2); } else if (resultType instanceof BigIntegerType) { result = ((BigInteger) o1).add((BigInteger) o2); } else if (resultType instanceof DoubleType) { result = ((Double) o1).doubleValue() + ((Double) o2).doubleValue(); } else { result = ((Long) o1).longValue() + ((Long) o2).longValue(); } return result; } private  Arith(); static Object add(Object operand1,
                             Object operand2,
                             Type resultType); static Type promote(Type operand1,
                               Type operand2);  }