in bval-jsr/src/main/java/org/apache/bval/util/reflection/TypeUtils.java [663:699]
private static boolean isAssignable(final Type type, final TypeVariable<?> toTypeVariable,
final Map<TypeVariable<?>, Type> typeVarAssigns) {
if (type == null) {
return true;
}
// only a null type can be assigned to null type which
// would have cause the previous to return true
if (toTypeVariable == null) {
return false;
}
// all types are assignable to themselves
if (toTypeVariable.equals(type)) {
return true;
}
if (type instanceof TypeVariable<?>) {
// a type variable is assignable to another type variable, if
// and only if the former is the latter, extends the latter, or
// is otherwise a descendant of the latter.
final Type[] bounds = getImplicitBounds((TypeVariable<?>) type);
for (final Type bound : bounds) {
if (isAssignable(bound, toTypeVariable, typeVarAssigns)) {
return true;
}
}
}
if (type instanceof Class<?> || type instanceof ParameterizedType
|| type instanceof GenericArrayType || type instanceof WildcardType) {
return false;
}
throw new IllegalStateException("found an unhandled type: " + type);
}