Source:
<code>private static Object objectConvert(Object value, Class<?> type) { Object result = value; String typeName = type.getSimpleName(); if (value instanceof BigDecimal && !type.equals(BigDecimal.class)) { BigDecimal bdValue = (BigDecimal) value; if (type.equals(Float.class) || typeName.equals("float")) { result = bdValue.floatValue(); } else if (type.equals(Double.class) || typeName.equals("double")) { result = bdValue.doubleValue(); } else if (type.equals(Long.class) || typeName.equals("long")) { result = bdValue.longValue(); } else if (type.equals(Integer.class) || typeName.equals("int")) { result = bdValue.intValue(); } } else if (value instanceof String && !type.equals(String.class)) { String bdValue = (String) value; if (type.equals(Float.class) || typeName.equals("float")) { result = Float.valueOf(bdValue); } else if (type.equals(Double.class) || typeName.equals("double")) { result = Double.valueOf(bdValue); } else if (type.equals(Long.class) || typeName.equals("long")) { result = Long.valueOf(bdValue); } else if (type.equals(BigDecimal.class)) { result = new BigDecimal(bdValue); } else if (type.equals(Integer.class) || typeName.equals("int")) { result = Integer.valueOf(bdValue); } else if (type.equals(Boolean.class) || typeName.equals("boolean")) { result = Boolean.valueOf(bdValue); } else if (type.isEnum()) { @SuppressWarnings({ "rawtypes" }) final Class<? extends Enum> enumType = (Class<? extends Enum>) type; <START> return Enum.valueOf(enumType, value.toString()); <END> } } return result; }</code><technical_language>handle IllegalArgumentExceptions here</technical_language>

Target:
private static Object objectConvert(Object value, Class<?> type) { Object result = value; String typeName = type.getSimpleName(); if (value instanceof BigDecimal && !type.equals(BigDecimal.class)) { BigDecimal bdValue = (BigDecimal) value; if (type.equals(Float.class) || typeName.equals("float")) { result = bdValue.floatValue(); } else if (type.equals(Double.class) || typeName.equals("double")) { result = bdValue.doubleValue(); } else if (type.equals(Long.class) || typeName.equals("long")) { result = bdValue.longValue(); } else if (type.equals(Integer.class) || typeName.equals("int")) { result = bdValue.intValue(); } } else if (value instanceof String && !type.equals(String.class)) { String bdValue = (String) value; if (type.equals(Float.class) || typeName.equals("float")) { result = Float.valueOf(bdValue); } else if (type.equals(Double.class) || typeName.equals("double")) { result = Double.valueOf(bdValue); } else if (type.equals(Long.class) || typeName.equals("long")) { result = Long.valueOf(bdValue); } else if (type.equals(BigDecimal.class)) { result = new BigDecimal(bdValue); } else if (type.equals(Integer.class) || typeName.equals("int")) { result = Integer.valueOf(bdValue); } else if (type.equals(Boolean.class) || typeName.equals("boolean")) { result = Boolean.valueOf(bdValue); } else if (type.isEnum()) { @SuppressWarnings({ "rawtypes", "unchecked" }) final Class<? extends Enum> enumType = (Class<? extends Enum>) type; @SuppressWarnings({ "unchecked" }) final Enum<?> enumvalue = Enum.valueOf(enumType, value.toString()); result = enumvalue; } } return result; }