public static Object convertToClass ( String value , Class < ? > clazz ) { Object propertyValue ; if ( clazz . isAssignableFrom ( int . class ) ) { propertyValue = Integer . parseInt ( value ) ; } else if ( clazz . isAssignableFrom ( long . class ) ) { propertyValue = Long . parseLong ( value ) ; } else if ( clazz . isAssignableFrom ( float . class ) ) { propertyValue = Float . parseFloat ( value ) ; } else if ( clazz . isAssignableFrom ( boolean . class ) ) { propertyValue = Boolean . parseBoolean ( value ) ; } else { propertyValue = value ; } return propertyValue ; }
Converts a value to the type of the given field .