@Override public boolean isSubtypeOf(String fullyQualifiedName) { return erasure().isSubtypeOf(fullyQualifiedName); }
@Override public boolean isSubtypeOf(String fullyQualifiedName) { return erasure().isSubtypeOf(fullyQualifiedName); }
@VisibleForTesting Set<Type> supertypes(JavaType type) { List<Type> result = new ArrayList<>(); result.add(type); Symbol.TypeSymbol symbol = type.symbol(); TypeSubstitution substitution = getTypeSubstitution(type); if(substitution.size() == 0 && !((JavaSymbol.TypeJavaSymbol) symbol).typeVariableTypes.isEmpty()) { // raw type : let's create a substitution based on erasures TypeSubstitution ts = new TypeSubstitution(); ((JavaSymbol.TypeJavaSymbol) symbol).typeVariableTypes.forEach(t -> ts.add(t, t.erasure())); substitution = ts; } result.addAll(interfacesWithSubstitution(symbol, substitution)); Type superClass = symbol.superClass(); while (superClass != null) { JavaType substitutedSuperClass = applySubstitution(superClass, substitution); result.add(substitutedSuperClass); substitution = getTypeSubstitution(substitutedSuperClass); JavaSymbol.TypeJavaSymbol superClassSymbol = substitutedSuperClass.getSymbol(); result.addAll(interfacesWithSubstitution(superClassSymbol, substitution)); superClass = superClassSymbol.superClass(); } return new LinkedHashSet<>(result); }
@VisibleForTesting Set<Type> supertypes(JavaType type) { List<Type> result = new ArrayList<>(); result.add(type); Symbol.TypeSymbol symbol = type.symbol(); TypeSubstitution substitution = getTypeSubstitution(type); if(substitution.size() == 0 && !((JavaSymbol.TypeJavaSymbol) symbol).typeVariableTypes.isEmpty()) { // raw type : let's create a substitution based on erasures TypeSubstitution ts = new TypeSubstitution(); ((JavaSymbol.TypeJavaSymbol) symbol).typeVariableTypes.forEach(t -> ts.add(t, t.erasure())); substitution = ts; } result.addAll(interfacesWithSubstitution(symbol, substitution)); Type superClass = symbol.superClass(); while (superClass != null) { JavaType substitutedSuperClass = applySubstitution(superClass, substitution); result.add(substitutedSuperClass); substitution = getTypeSubstitution(substitutedSuperClass); JavaSymbol.TypeJavaSymbol superClassSymbol = substitutedSuperClass.getSymbol(); result.addAll(interfacesWithSubstitution(superClassSymbol, substitution)); superClass = superClassSymbol.superClass(); } return new LinkedHashSet<>(result); }