private boolean isSubtypeOf ( String class1 , String class2 ) { if ( class1 == null || class2 == null ) { return false ; } class1 = convertToNonPrimitiveClass ( class1 ) ; class2 = convertToNonPrimitiveClass ( class2 ) ; // TODO add code to take primitive types into account ClassTypeResolver resolver = new ClassTypeResolver ( getUniqueImports ( ) , ProjectClassLoader . getProjectClassLoader ( getEditor ( ) ) ) ; try { Class < ? > clazz1 = resolver . resolveType ( class1 ) ; Class < ? > clazz2 = resolver . resolveType ( class2 ) ; if ( clazz1 == null || clazz2 == null ) { return false ; } return clazz2 . isAssignableFrom ( clazz1 ) ; } catch ( ClassNotFoundException exc ) { return false ; } }
Returns true if the first class is the same or a subtype of the second class .