Skip to content

Commit

Permalink
Fix quality flaw: reduce complexity by method
Browse files Browse the repository at this point in the history
  • Loading branch information
benzonico committed Jun 28, 2016
1 parent d1fa847 commit 969cfaf
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,24 @@ public boolean isSubtypeOf(Type superType) {
if (((JavaType) superType).isTagged(TYPEVAR)) {
return false;
}
if(erasure() == superType.erasure()) {
if (((JavaType) superType).isParameterized()) {
return checkSubstitutedTypesCompatibility((ParametrizedTypeJavaType) superType);
}
if (erasure() == superType.erasure()) {
return !((JavaType) superType).isParameterized() || checkSubstitutedTypesCompatibility((ParametrizedTypeJavaType) superType);
}
if (verifySuperTypes(superType)) {
return true;
}
return ((JavaType) superType).isTagged(WILDCARD) && ((WildCardType) superType).isSubtypeOfBound(this);
}

private boolean verifySuperTypes(Type superType) {
JavaType superclass = symbol.getSuperclass();
if(superclass != null) {
if (superclass != null) {
superclass = typeSubstitutionSolver.applySubstitution(superclass, this.typeSubstitution);
if(superclass.isSubtypeOf(superType)) {
if (superclass.isSubtypeOf(superType)) {
return true;
}
}
for (JavaType superInterface : symbol.getInterfaces()) {
superclass = typeSubstitutionSolver.applySubstitution(superInterface, this.typeSubstitution);
if(superclass.isSubtypeOf(superType)) {
return true;
}
}
if (((JavaType) superType).isTagged(WILDCARD)) {
return ((WildCardType) superType).isSubtypeOfBound(this);
}
return false;
return symbol.getInterfaces().stream().map(si -> typeSubstitutionSolver.applySubstitution(si, this.typeSubstitution)).anyMatch(si -> si.isSubtypeOf(superType));
}

private boolean checkSubstitutedTypesCompatibility(ParametrizedTypeJavaType superType) {
Expand Down

0 comments on commit 969cfaf

Please sign in to comment.