private static boolean isAssignableFrom ( Type from , GenericArrayType to ) { Type toGenericComponentType = to . getGenericComponentType ( ) ; if ( toGenericComponentType instanceof ParameterizedType ) { Type t = from ; if ( from instanceof GenericArrayType ) { t = ( ( GenericArrayType ) from ) . getGenericComponentType ( ) ; } else if ( from instanceof Class ) { Class < ? > classType = ( Class < ? > ) from ; while ( classType . isArray ( ) ) { classType = classType . getComponentType ( ) ; } t = classType ; } return isAssignableFrom ( t , ( ParameterizedType ) toGenericComponentType , new HashMap < String , Type > ( ) ) ; } // No generic defined on "to"; therefore, return true and let other // checks determine assignability return true ; }
Private helper function that performs some assignability checks for the provided GenericArrayType .