public T mapObject ( final Map < String , String > values ) throws Exception { T result = createInstance ( ) ; // for each field for ( Map . Entry < String , String > entry : values . entrySet ( ) ) { String field = entry . getKey ( ) ; //get field raw value String value = values . get ( field ) ; Method setter = setters . get ( field ) ; if ( setter == null ) { LOGGER . warn ( "No public setter found for field {}, this field will be set to null (if object type) or default value (if primitive type)" , field ) ; continue ; } Class < ? > type = setter . getParameterTypes ( ) [ 0 ] ; TypeConverter < String , ? > typeConverter = typeConverters . get ( type ) ; if ( typeConverter == null ) { LOGGER . warn ( "Type conversion not supported for type {}, field {} will be set to null (if object type) or default value (if primitive type)" , type , field ) ; continue ; } if ( value == null ) { LOGGER . warn ( "Attempting to convert null to type {} for field {}, this field will be set to null (if object type) or default value (if primitive type)" , type , field ) ; continue ; } if ( value . isEmpty ( ) ) { LOGGER . debug ( "Attempting to convert an empty string to type {} for field {}, this field will be ignored" , type , field ) ; continue ; } convertValue ( result , field , value , setter , type , typeConverter ) ; } return result ; }
Map values to fields of the target object type .