private static boolean isMostPreciseType(Type variableType, Type collectionItemType) { if (collectionItemType instanceof WildCardType) { return ((WildCardType) collectionItemType).isSubtypeOfBound((JavaType) variableType); } else if (collectionItemType instanceof ParametrizedTypeJavaType) { return ((ParametrizedTypeJavaType) collectionItemType).erasure().equals(variableType.erasure()); } else { return variableType.equals(collectionItemType); } }
private static boolean isMostPreciseType(Type variableType, Type collectionItemType) { if (collectionItemType instanceof WildCardType) { return ((WildCardType) collectionItemType).isSubtypeOfBound((JavaType) variableType); } else if (collectionItemType instanceof ParametrizedTypeJavaType) { return ((ParametrizedTypeJavaType) collectionItemType).erasure().equals(variableType.erasure()); } else { return variableType.equals(collectionItemType); } }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; // Handle covariance of arrays. if (supType.isTagged(ARRAY)) { return elementType.isSubtypeOf(((ArrayType) supType).elementType()); } if (supType.isTagged(WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } // Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; // Handle covariance of arrays. if (supType.isTagged(ARRAY)) { return elementType.isSubtypeOf(((ArrayType) supType).elementType()); } if (supType.isTagged(WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } // Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); }
@Override public boolean isSubtypeOf(Type superType) { if (isTagged(BOT)) { return ((JavaType) superType).isTagged(BOT) || superType.isClass() || superType.isArray(); } if (((JavaType) superType).isTagged(JavaType.WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } if (superType.isClass()) { ClassJavaType superClassType = (ClassJavaType) superType; return this.equals(superClassType) || superTypeIsSubTypeOf(superClassType); } return false; }
@Override public boolean isSubtypeOf(Type superType) { if (isTagged(BOT)) { return ((JavaType) superType).isTagged(BOT) || superType.isClass() || superType.isArray(); } if (((JavaType) superType).isTagged(JavaType.WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } if (superType.isClass()) { ClassJavaType superClassType = (ClassJavaType) superType; return this.equals(superClassType) || superTypeIsSubTypeOf(superClassType); } return false; }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; if (supType.isTagged(WILDCARD)) { return ((WildCardType) supType).isSubtypeOfBound(this); } if (supType == this) { return true; } for (JavaType bound : bounds()) { if (bound.isSubtypeOf(supType) || (supType.isParameterized() && bound == supType.erasure())) { return true; } } return false; } }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; if (supType.isTagged(WILDCARD)) { return ((WildCardType) supType).isSubtypeOfBound(this); } if (supType == this) { return true; } for (JavaType bound : bounds()) { if (bound.isSubtypeOf(supType) || (supType.isParameterized() && bound == supType.erasure())) { return true; } } return false; } }
@Override public boolean isSubtypeOf(Type superType) { if (((JavaType) superType).isTagged(TYPEVAR)) { return false; } 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); }
@Override public boolean isSubtypeOf(Type superType) { if (((JavaType) superType).isTagged(TYPEVAR)) { return false; } 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); }