ResolvableType.java.forRawClass(Class) supports isAssignableFrom(ResolvableType) as well

Issue: SPR-14648
(cherry picked from commit 086e764)
This commit is contained in:
Juergen Hoeller
2016-08-31 14:45:22 +02:00
parent a3b94eb17c
commit 5f55add4bb
2 changed files with 27 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -276,7 +276,7 @@ public class ResolvableType implements Serializable {
WildcardBounds ourBounds = WildcardBounds.get(this);
WildcardBounds typeBounds = WildcardBounds.get(other);
// In the from X is assignable to <? extends Number>
// In the form X is assignable to <? extends Number>
if (typeBounds != null) {
return (ourBounds != null && ourBounds.isSameKind(typeBounds) &&
ourBounds.isAssignableFrom(typeBounds.getBounds()));
@@ -937,7 +937,7 @@ public class ResolvableType implements Serializable {
* Return a {@link ResolvableType} for the specified {@link Class}, doing
* assignability checks against the raw class only (analogous to
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
* For example: {@code ResolvableType.forClass(MyArrayList.class)}.
* For example: {@code ResolvableType.forRawClass(List.class)}.
* @param sourceClass the source class ({@code null} is semantically
* equivalent to {@code Object.class} for typical use cases here}
* @return a {@link ResolvableType} for the specified class
@@ -951,6 +951,11 @@ public class ResolvableType implements Serializable {
public boolean isAssignableFrom(Class<?> other) {
return ClassUtils.isAssignable(getRawClass(), other);
}
@Override
public boolean isAssignableFrom(ResolvableType other) {
Class<?> otherClass = other.getRawClass();
return (otherClass != null && ClassUtils.isAssignable(getRawClass(), otherClass));
}
};
}