ResolvableType-based type matching at the BeanFactory API level

Issue: SPR-12147
This commit is contained in:
Juergen Hoeller
2015-03-18 23:05:13 +01:00
parent a3e5fbf5ed
commit 778a01943b
14 changed files with 323 additions and 102 deletions

View File

@@ -156,7 +156,7 @@ public final class ResolvableType implements Serializable {
}
/**
* Return the underlying Java {@link Class} being managed, if available;
* Return the underlying Java {@link Class} being managed, if available;
* otherwise {@code null}.
*/
public Class<?> getRawClass() {
@@ -179,6 +179,27 @@ public final class ResolvableType implements Serializable {
return (source != null ? source : this.type);
}
/**
* Determine whether the given object is an instance of this {@code ResolvableType}.
* @param obj the object to check
* @since 4.2
* @see #isAssignableFrom(Class)
*/
public boolean isInstance(Object obj) {
return (obj != null && isAssignableFrom(obj.getClass()));
}
/**
* Determine whether this {@code ResolvableType} is assignable from the
* specified other type.
* @param other the type to be checked against (as a {@code Class})
* @since 4.2
* @see #isAssignableFrom(ResolvableType)
*/
public boolean isAssignableFrom(Class<?> other) {
return isAssignableFrom(forClass(other), null);
}
/**
* Determine whether this {@code ResolvableType} is assignable from the
* specified other type.
@@ -186,7 +207,7 @@ public final class ResolvableType implements Serializable {
* whether both the {@link #resolve() resolved} {@code Class} is
* {@link Class#isAssignableFrom(Class) assignable from} the given type
* as well as whether all {@link #getGenerics() generics} are assignable.
* @param other the type to be checked against
* @param other the type to be checked against (as a {@code ResolvableType})
* @return {@code true} if the specified other type can be assigned to this
* {@code ResolvableType}; {@code false} otherwise
*/