ResolvableType.java.forRawClass(Class) supports isAssignableFrom(ResolvableType) as well
Issue: SPR-14648
(cherry picked from commit 086e764)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user