protected Object convertUserDefinedValueType ( Object object , Class < ? > type ) { if ( type . isAssignableFrom ( object . getClass ( ) ) ) { return object ; } else if ( object instanceof String ) { try { Constructor < ? > constructor = type . getConstructor ( String . class ) ; return constructor . newInstance ( object ) ; } catch ( Exception e ) { logger . debug ( "Cannot invoke [public " + type . getName ( ) + "(String.class)] constrcutor on [" + type + "]" , e ) ; } try { return type . getMethod ( "valueOf" , String . class ) . invoke ( null , object ) ; } catch ( Exception e1 ) { logger . debug ( "Cannot invoke [public static " + type . getName ( ) + ".valueOf(String.class)]" + "method on [" + type + "]" , e1 ) ; } } else { logger . warn ( "Parameter [" + object + "] cannot be converted to [" + type + "]" ) ; } return null ; }
Converts the specified object to the specified user - defined value type . This method is overridable . You can provide your own conversion to the parameter construction by overriding this method .