@SuppressWarnings("unchecked")
    static <T> T stringToType(String str, Class<T> clazz) {
        try {
            final Function<String, ?> func = supportedElementTypes.get(clazz);
            if (func != null) {
                return (T) func.apply(str);
            }
        } catch (NumberFormatException e) {
            throw e;
        } catch (Throwable cause) {
            throw new IllegalArgumentException(
                    "Can't convert '" + str + "' to type '" + clazz.getSimpleName() + "'.", cause);
        }

        throw new IllegalArgumentException(
                "Can't convert '" + str + "' to type '" + clazz.getSimpleName() + "'.");
    }
@ SuppressWarnings ( "unchecked" ) static < T > T stringToType ( String str , Class < T > clazz ) { try { final Function < String , ? > func = supportedElementTypes . get ( clazz ) ; if ( func != null ) { return ( T ) func . apply ( str ) ; } } catch ( NumberFormatException e ) { throw e ; } catch ( Throwable cause ) { throw new IllegalArgumentException ( "Can't convert '" + str + "' to type '" + clazz . getSimpleName ( ) + "'." , cause ) ; } throw new IllegalArgumentException ( "Can't convert '" + str + "' to type '" + clazz . getSimpleName ( ) + "'." ) ; }
Converts the given {@code str} to {@code T} type object. e.g., "42" -> 42.

@throws IllegalArgumentException if {@code str} can't be deserialized to {@code T} type object.