Consistent instanceof/casting of Class references

This commit is contained in:
Juergen Hoeller
2016-10-30 21:40:27 +01:00
parent 7627c38695
commit ac80ac6f8b
13 changed files with 35 additions and 39 deletions

View File

@@ -1078,10 +1078,10 @@ public abstract class AnnotationUtils {
boolean nestedAnnotationsAsMap) {
if (classValuesAsString) {
if (value instanceof Class<?>) {
if (value instanceof Class) {
return ((Class<?>) value).getName();
}
else if (value instanceof Class<?>[]) {
else if (value instanceof Class[]) {
Class<?>[] clazzArray = (Class<?>[]) value;
String[] classNames = new String[clazzArray.length];
for (int i = 0; i < clazzArray.length; i++) {

View File

@@ -80,10 +80,10 @@ abstract class AnnotationReadingVisitorUtils {
value = convArray;
}
else if (classValuesAsString) {
if (value instanceof Class<?>) {
if (value instanceof Class) {
value = ((Class<?>) value).getName();
}
else if (value instanceof Class<?>[]) {
else if (value instanceof Class[]) {
Class<?>[] clazzArray = (Class<?>[]) value;
String[] newValue = new String[clazzArray.length];
for (int i = 0; i < clazzArray.length; i++) {

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.
@@ -48,11 +48,11 @@ public abstract class TypeUtils {
return true;
}
if (lhsType instanceof Class<?>) {
if (lhsType instanceof Class) {
Class<?> lhsClass = (Class<?>) lhsType;
// just comparing two classes
if (rhsType instanceof Class<?>) {
if (rhsType instanceof Class) {
return ClassUtils.isAssignable(lhsClass, (Class<?>) rhsType);
}
@@ -60,7 +60,7 @@ public abstract class TypeUtils {
Type rhsRaw = ((ParameterizedType) rhsType).getRawType();
// a parameterized type is always assignable to its raw class type
if (rhsRaw instanceof Class<?>) {
if (rhsRaw instanceof Class) {
return ClassUtils.isAssignable(lhsClass, (Class<?>) rhsRaw);
}
}
@@ -73,10 +73,10 @@ public abstract class TypeUtils {
// parameterized types are only assignable to other parameterized types and class types
if (lhsType instanceof ParameterizedType) {
if (rhsType instanceof Class<?>) {
if (rhsType instanceof Class) {
Type lhsRaw = ((ParameterizedType) lhsType).getRawType();
if (lhsRaw instanceof Class<?>) {
if (lhsRaw instanceof Class) {
return ClassUtils.isAssignable((Class<?>) lhsRaw, (Class<?>) rhsType);
}
}
@@ -88,7 +88,7 @@ public abstract class TypeUtils {
if (lhsType instanceof GenericArrayType) {
Type lhsComponent = ((GenericArrayType) lhsType).getGenericComponentType();
if (rhsType instanceof Class<?>) {
if (rhsType instanceof Class) {
Class<?> rhsClass = (Class<?>) rhsType;
if (rhsClass.isArray()) {