@Override public Object convertToTargetType(String propertyValue, Class targetClass) throws ConfigBuilderException { return targetClass == String.class ? propertyValue : mapToEnumOrPrimitiveWrapper(propertyValue, targetClass); }
private Object mapToEnumOrPrimitiveWrapper(String propertyValue, Class targetClass) throws ConfigBuilderException { Object result; try { if ( targetClass.isEnum()) { result = mapToEnum(propertyValue, targetClass); } else { result = mapToPrimitiveWrapper(propertyValue, targetClass); } } catch (NumberFormatException nfe) { throw new ConfigBuilderException(getClass().getSimpleName() + " could not convert the property value '" + propertyValue + "' to a " + targetClass.getName()); } return result; }