@Test public void testGetBigDecimalValue() { try { StreamClassUtil.getBigDecimalValue(null); fail(); } catch (IllegalArgumentException e) { Assert.assertTrue(true); } try { Assert.assertEquals(new BigDecimal(1), StreamClassUtil.getBigDecimalValue(new BigDecimal(1))); Assert.assertEquals(new BigDecimal(1.0d), StreamClassUtil.getBigDecimalValue(new Float(1))); Assert.assertEquals(new BigDecimal(1.0d), StreamClassUtil.getBigDecimalValue(new Double(1))); Assert.assertEquals(new BigDecimal(1), StreamClassUtil.getBigDecimalValue(new Integer(1))); Assert.assertEquals(new BigDecimal(1), StreamClassUtil.getBigDecimalValue(new Long(1))); } catch (IllegalArgumentException e) { fail(); } }
public static BigDecimal getBigDecimalValue(Number result) { if (result == null) { String msg = "Parameter must not null."; LOG.error(msg); throw new IllegalArgumentException(msg); } if (result.getClass() == BigDecimal.class) { return (BigDecimal)result; } if (isFloatingPointNumber(result)) { return new BigDecimal(result.doubleValue()); } return new BigDecimal(result.longValue()); }
StreamClassUtil { public static BigDecimal getBigDecimalValue(Number result) { if (result == null) { String msg = "Parameter must not null."; LOG.error(msg); throw new IllegalArgumentException(msg); } if (result.getClass() == BigDecimal.class) { return (BigDecimal)result; } if (isFloatingPointNumber(result)) { return new BigDecimal(result.doubleValue()); } return new BigDecimal(result.longValue()); } }
StreamClassUtil { public static BigDecimal getBigDecimalValue(Number result) { if (result == null) { String msg = "Parameter must not null."; LOG.error(msg); throw new IllegalArgumentException(msg); } if (result.getClass() == BigDecimal.class) { return (BigDecimal)result; } if (isFloatingPointNumber(result)) { return new BigDecimal(result.doubleValue()); } return new BigDecimal(result.longValue()); }  }
StreamClassUtil { public static BigDecimal getBigDecimalValue(Number result) { if (result == null) { String msg = "Parameter must not null."; LOG.error(msg); throw new IllegalArgumentException(msg); } if (result.getClass() == BigDecimal.class) { return (BigDecimal)result; } if (isFloatingPointNumber(result)) { return new BigDecimal(result.doubleValue()); } return new BigDecimal(result.longValue()); }  static Class< ? > getWrapType(Class< ? > type); static boolean isNumberic(Class< ? > type); static Class< ? > getArithmaticType(Class< ? > leftType, Class< ? > rightType); static Class< ? > getCommonType(List<Class< ? >> childTypes); static Number getNumbericValueForType(Number result, Class< ? > resultType); static BigDecimal getBigDecimalValue(Number result); static boolean isFloatingPointNumber(Number value); static Class< ? > getCompareType(Class< ? > typeOne, Class< ? > typeTwo); static boolean isBoolean(Class< ? > type); static boolean isDateOrTimestamp(Class< ? > type); }
StreamClassUtil { public static BigDecimal getBigDecimalValue(Number result) { if (result == null) { String msg = "Parameter must not null."; LOG.error(msg); throw new IllegalArgumentException(msg); } if (result.getClass() == BigDecimal.class) { return (BigDecimal)result; } if (isFloatingPointNumber(result)) { return new BigDecimal(result.doubleValue()); } return new BigDecimal(result.longValue()); }  static Class< ? > getWrapType(Class< ? > type); static boolean isNumberic(Class< ? > type); static Class< ? > getArithmaticType(Class< ? > leftType, Class< ? > rightType); static Class< ? > getCommonType(List<Class< ? >> childTypes); static Number getNumbericValueForType(Number result, Class< ? > resultType); static BigDecimal getBigDecimalValue(Number result); static boolean isFloatingPointNumber(Number value); static Class< ? > getCompareType(Class< ? > typeOne, Class< ? > typeTwo); static boolean isBoolean(Class< ? > type); static boolean isDateOrTimestamp(Class< ? > type);  }