public static Class < Object > loadValidInputTypes ( String javaType , String type ) { // we have generics in the javatype, if so remove it so its loadable from a classloader int idx = javaType . indexOf ( ' ' ) ; if ( idx > 0 ) { javaType = javaType . substring ( 0 , idx ) ; } try { Class < Object > clazz = getPrimitiveWrapperClassType ( type ) ; if ( clazz == null ) { clazz = loadPrimitiveWrapperType ( javaType ) ; } if ( clazz == null ) { clazz = loadStringSupportedType ( javaType ) ; } if ( clazz == null ) { try { clazz = ( Class < Object > ) Class . forName ( javaType ) ; } catch ( Throwable e ) { // its a custom java type so use String as the input type, so you can refer to it using # lookup if ( "object" . equals ( type ) ) { clazz = loadPrimitiveWrapperType ( "java.lang.String" ) ; } } } // favor specialized UI for these types if ( clazz != null && ( clazz . equals ( String . class ) || clazz . equals ( Date . class ) || clazz . equals ( Boolean . class ) || clazz . isPrimitive ( ) || Number . class . isAssignableFrom ( clazz ) ) ) { return clazz ; } // its a custom java type so use String as the input type, so you can refer to it using # lookup if ( "object" . equals ( type ) ) { clazz = loadPrimitiveWrapperType ( "java.lang.String" ) ; return clazz ; } } catch ( Throwable e ) { // ignore errors } return null ; }
Converts a java type as a string to a valid input type and returns the class or null if its not supported