else if (Float.TYPE.equals(clazz))
return number.floatValue();
else if (Float.class.equals(clazz))
return new Float(number.floatValue());
else if (BigDecimal.class.equals(clazz))
return new BigDecimal(number.doubleValue());
else if (BigInteger.class.equals(clazz))
return new BigInteger(number.toString());
// else
// TODO log warn
} else if (isDateTime(clazz)) {
return handleAsDate(clazz,value,customizeInfo,method);
} else if (clazz.isEnum()) {
String sValue = (value instanceof Map) ? ((String)((Map)value).get("_name")) : (String) value;
try{
return Enum.valueOf(clazz, sValue);
}catch(Throwable th){
// try in value fields
for(Object conzt: clazz.getEnumConstants()){
try{
// If xml value annotation use it.
if(clazz.getDeclaredField(((Enum<?>)conzt).name()).
getAnnotation(XmlEnumValue.class).value().equals(sValue)){
return conzt;
}
}catch(Throwable t){};
}
// user error?
return null;
}
} else if (value instanceof String) {
String sValue = (String) value;
if(sValue.trim().isEmpty() && Number.class.isAssignableFrom(clazz)){
sValue = "0";
if(traceEnabled)traceLog.warn("Empty string passed for number. Converting it to zero. Field : " + method.getName());
}
if (String.class.equals(clazz))
return value;
else if (Boolean.TYPE.equals(clazz))
return Boolean.parseBoolean(sValue);
else if (Boolean.class.equals(clazz))
return Boolean.valueOf(sValue);
else if (Short.TYPE.equals(clazz) || Short.class.equals(clazz))
return Short.decode(sValue);
else if (Byte.TYPE.equals(clazz) || Byte.class.equals(clazz))
return Byte.decode(sValue);
else if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz))
return Integer.decode(sValue);
else if (Long.TYPE.equals(clazz) || Long.class.equals(clazz))
return Long.decode(sValue);
else if (Float.TYPE.equals(clazz))
return Float.parseFloat(sValue);
else if (Float.class.equals(clazz))
return Float.valueOf(sValue);
else if (Double.TYPE.equals(clazz))
return Double.parseDouble(sValue);
else if (Double.class.equals(clazz))
return Double.valueOf(sValue);
else if (BigDecimal.class.equals(clazz))
return new BigDecimal(sValue);
else if (BigInteger.class.equals(clazz))
return new BigInteger(sValue);
else if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) {
char charValue = 0;
if (sValue.length() > 0) {