@Override public Void visitWildcard(final WildcardType source, final TypeReference target) { if (source.hasExtendsBound()) { adaptRecursive(getUpperBound(source), getUpperBound(target)); } else if (source.hasSuperBound()) { adaptRecursive(getLowerBound(source), getLowerBound(target)); } return null; }
@Override public Void visitWildcard(final WildcardType source, final TypeReference target) { if (source.hasExtendsBound()) { adaptRecursive(getUpperBound(source), getUpperBound(target)); } else if (source.hasSuperBound()) { adaptRecursive(getLowerBound(source), getLowerBound(target)); } return null; }
@Override public Void visitWildcard(final WildcardType source, final TypeReference target) { if (source.hasExtendsBound()) { adaptRecursive(getUpperBound(source), getUpperBound(target)); } else if (source.hasSuperBound()) { adaptRecursive(getLowerBound(source), getLowerBound(target)); } return null; }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { return isSameWildcard(t, s) || isCaptureOf(s, t) || (t.hasExtendsBound() || isSubTypeNoCapture(L(t), getLowerBound(s))) && (t.hasSuperBound() || isSubTypeNoCapture(getUpperBound(s), U(t))); } };
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { return isSameWildcard(t, s) || isCaptureOf(s, t) || (t.hasExtendsBound() || isSubTypeNoCapture(L(t), getLowerBound(s))) && (t.hasSuperBound() || isSubTypeNoCapture(getUpperBound(s), U(t))); } };
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { return isSameWildcard(t, s) || isCaptureOf(s, t) || (t.hasExtendsBound() || isSubTypeNoCapture(L(t), getLowerBound(s))) && (t.hasSuperBound() || isSubTypeNoCapture(getUpperBound(s), U(t))); } };
@Override @SuppressWarnings("StatementWithEmptyBody") public Void visitGenericParameter(final GenericParameter source, final TypeReference target) { TypeReference value = mapping.get(source); if (value != null) { if (value.hasSuperBound() && target.hasSuperBound()) { value = isSubType(getLowerBound(value), getLowerBound(target)) ? target : value; } else if (value.hasExtendsBound() && target.hasExtendsBound()) { value = isSubType(getUpperBound(value), getUpperBound(target)) ? value : target; } else if (value.isWildcardType() && value.isUnbounded()) { // do nothing } else if (!isSameType(value, target)) { throw new AdaptFailure(); } } else { value = target; from.append(source); to.append(target); } mapping.put(source, value); return null; } }
@Override public Void visitGenericParameter(final GenericParameter source, final TypeReference target) { TypeReference value = mapping.get(source); if (value != null) { if (value.hasSuperBound() && target.hasSuperBound()) { value = isSubType(getLowerBound(value), getLowerBound(target)) ? target : value; } else if (value.hasExtendsBound() && target.hasExtendsBound()) { value = isSubType(getUpperBound(value), getUpperBound(target)) ? value : target; } else if (value.isWildcardType() && value.isUnbounded()) { // do nothing } else if (!isSameType(value, target)) { throw new AdaptFailure(); } } else { value = target; from.append(source); to.append(target); } mapping.put(source, value); return null; } }
@Override public Void visitGenericParameter(final GenericParameter source, final TypeReference target) { TypeReference value = mapping.get(source); if (value != null) { if (value.hasSuperBound() && target.hasSuperBound()) { value = isSubType(getLowerBound(value), getLowerBound(target)) ? target : value; } else if (value.hasExtendsBound() && target.hasExtendsBound()) { value = isSubType(getUpperBound(value), getUpperBound(target)) ? value : target; } else if (value.isWildcardType() && value.isUnbounded()) { // do nothing } else if (!isSameType(value, target)) { throw new AdaptFailure(); } } else { value = target; from.append(source); to.append(target); } mapping.put(source, value); return null; } }
public static boolean isSubType(final TypeReference type, final TypeReference baseType, final boolean capture) { if (type == baseType) { return true; } if (type == null || baseType == null) { return false; } if (baseType instanceof CompoundTypeReference) { final CompoundTypeReference c = (CompoundTypeReference) baseType; if (!isSubType(type, getSuperType(c), capture)) { return false; } for (final TypeReference interfaceType : c.getInterfaces()) { if (!isSubType(type, interfaceType, capture)) { return false; } } return true; } final TypeReference lower = getLowerBound(baseType); if (lower != baseType) { return isSubType(capture ? capture(type) : type, lower, false); } return IS_SUBTYPE_VISITOR.visit(capture ? capture(type) : type, baseType); }
public static boolean isSubType(final TypeReference type, final TypeReference baseType, final boolean capture) { if (type == baseType) { return true; } if (type == null || baseType == null) { return false; } if (baseType instanceof CompoundTypeReference) { final CompoundTypeReference c = (CompoundTypeReference) baseType; if (!isSubType(type, getSuperType(c), capture)) { return false; } for (final TypeReference interfaceType : c.getInterfaces()) { if (!isSubType(type, interfaceType, capture)) { return false; } } return true; } final TypeReference lower = getLowerBound(baseType); if (lower != baseType) { return isSubType(capture ? capture(type) : type, lower, false); } return IS_SUBTYPE_VISITOR.visit(capture ? capture(type) : type, baseType); }
public static boolean isSubType(final TypeReference type, final TypeReference baseType, final boolean capture) { if (type == baseType) { return true; } if (type == null || baseType == null) { return false; } if (baseType instanceof CompoundTypeReference) { final CompoundTypeReference c = (CompoundTypeReference) baseType; if (!isSubType(type, getSuperType(c), capture)) { return false; } for (final TypeReference interfaceType : c.getInterfaces()) { if (!isSubType(type, interfaceType, capture)) { return false; } } return true; } final TypeReference lower = getLowerBound(baseType); if (lower != baseType) { return isSubType(capture ? capture(type) : type, lower, false); } return IS_SUBTYPE_VISITOR.visit(capture ? capture(type) : type, baseType); }