public static Object asScalarValue(Object bean) { Class<?> type = bean.getClass(); if (isBigInteger(type)) { return ((BigInteger) bean).intValue(); } else if (isBigDecimal(type)) { return ((BigDecimal) bean).doubleValue(); } else if (isCalendar(type)) { return ((Calendar) bean).getTime(); } else if (isDate(type)) { return ((Date) bean).getTime(); } else if (isCurrency(type)) { return ((Currency) bean).toString(); } else { return bean; } }
public static Object asScalarValue(Object bean) { Class<?> type = bean.getClass(); if (isBigInteger(type)) { return ((BigInteger) bean).intValue(); } else if (isBigDecimal(type)) { return ((BigDecimal) bean).doubleValue(); } else if (isCalendar(type)) { return ((Calendar) bean).getTime(); } else if (isDate(type)) { return ((Date) bean).getTime(); } else if (isCurrency(type)) { return ((Currency) bean).toString(); } else { return bean; } }
.getTime(); } else if (isCurrency(type)) { return Currency.getInstance(string); } else if (type.isEnum()) {
.getTime(); } else if (isCurrency(type)) { return Currency.getInstance(string); } else if (type.isEnum()) {
@Test public void testIsCurrency() throws Exception { Assert.assertTrue(DataType.isCurrency(Currency.class)); }
/** * Determines if the given class holds only one data item. Can be useful to determine if a value should be rendered * as scalar. * * @param clazz * to check * @return true if class is scalar */ public static boolean isSingleValueType(Class<?> clazz) { boolean ret; if (isNumber(clazz) || isBoolean(clazz) || isString(clazz) || isEnum(clazz) || isDate(clazz) || isCalendar(clazz) || isCurrency(clazz) ) { ret = true; } else { ret = false; } return ret; }
/** * Determines if the given class holds only one data item. Can be useful to determine if a value should be rendered * as scalar. * * @param clazz * to check * @return true if class is scalar */ public static boolean isSingleValueType(Class<?> clazz) { boolean ret; if (isNumber(clazz) || isBoolean(clazz) || isString(clazz) || isEnum(clazz) || isDate(clazz) || isCalendar(clazz) || isCurrency(clazz) ) { ret = true; } else { ret = false; } return ret; }