public static < T > T convert ( Object from , Class < ? extends T > to , Params arg ) { if ( from == null ) { throw new NullPointerException ( "from" ) ; } if ( to == null ) { throw new NullPointerException ( "to" ) ; } if ( from . getClass ( ) == String . class && to . isArray ( ) ) { return new ArrayConverter ( ( String ) from ) . getArrayForType ( to ) ; } // get it from the internal cache. @ SuppressWarnings ( "unchecked" ) Converter < Object , T > c = co . get ( key ( from . getClass ( ) , to ) ) ; if ( c == null ) { // service provider lookup c = lookupConversionService ( from . getClass ( ) , to ) ; if ( c == null ) { throw new ComponentException ( "No Converter: " + from + " (" + from . getClass ( ) + ") -> " + to ) ; } co . put ( key ( from . getClass ( ) , to ) , c ) ; } Object param = null ; if ( arg != null ) { param = arg . get ( from . getClass ( ) , to ) ; } return ( T ) c . convert ( from , param ) ; }
Convert a String value into an object of a certain type