private static Class < ? > extractClass ( Class < ? > ownerClass , Type arg ) { if ( arg instanceof ParameterizedType ) { return extractClass ( ownerClass , ( ( ParameterizedType ) arg ) . getRawType ( ) ) ; } else if ( arg instanceof GenericArrayType ) { GenericArrayType gat = ( GenericArrayType ) arg ; Type gt = gat . getGenericComponentType ( ) ; Class < ? > componentClass = extractClass ( ownerClass , gt ) ; return Array . newInstance ( componentClass , 0 ) . getClass ( ) ; } else if ( arg instanceof TypeVariable ) { TypeVariable tv = ( TypeVariable ) arg ; arg = getTypeVariableMap ( ownerClass ) . get ( tv ) ; if ( arg == null ) { arg = extractBoundForTypeVariable ( tv ) ; if ( arg instanceof ParameterizedType ) { return extractClass ( ownerClass , ( ( ParameterizedType ) arg ) . getRawType ( ) ) ; } } else { return extractClass ( ownerClass , arg ) ; } } return ( arg instanceof Class ? ( Class ) arg : Object . class ) ; }
Extract a Class from the given Type .