|
|
|
@ -65,6 +65,9 @@ public abstract class ClassUtils {
@@ -65,6 +65,9 @@ public abstract class ClassUtils {
|
|
|
|
|
/** Prefix for internal non-primitive array class names: {@code "[L"}. */ |
|
|
|
|
private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L"; |
|
|
|
|
|
|
|
|
|
/** A reusable empty class array constant. */ |
|
|
|
|
private static final Class<?>[] EMPTY_CLASS_ARRAY = {}; |
|
|
|
|
|
|
|
|
|
/** The package separator character: {@code '.'}. */ |
|
|
|
|
private static final char PACKAGE_SEPARATOR = '.'; |
|
|
|
|
|
|
|
|
@ -543,17 +546,12 @@ public abstract class ClassUtils {
@@ -543,17 +546,12 @@ public abstract class ClassUtils {
|
|
|
|
|
} |
|
|
|
|
if (lhsType.isPrimitive()) { |
|
|
|
|
Class<?> resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType); |
|
|
|
|
if (lhsType == resolvedPrimitive) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return (lhsType == resolvedPrimitive); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
Class<?> resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType); |
|
|
|
|
if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -681,8 +679,8 @@ public abstract class ClassUtils {
@@ -681,8 +679,8 @@ public abstract class ClassUtils {
|
|
|
|
|
* @since 3.1 |
|
|
|
|
* @see StringUtils#toStringArray |
|
|
|
|
*/ |
|
|
|
|
public static Class<?>[] toClassArray(Collection<Class<?>> collection) { |
|
|
|
|
return collection.toArray(new Class<?>[0]); |
|
|
|
|
public static Class<?>[] toClassArray(@Nullable Collection<Class<?>> collection) { |
|
|
|
|
return (!CollectionUtils.isEmpty(collection) ? collection.toArray(EMPTY_CLASS_ARRAY) : EMPTY_CLASS_ARRAY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1062,7 +1060,7 @@ public abstract class ClassUtils {
@@ -1062,7 +1060,7 @@ public abstract class ClassUtils {
|
|
|
|
|
* @param clazz the clazz to analyze |
|
|
|
|
* @param paramTypes the parameter types of the method |
|
|
|
|
* @return whether the class has a corresponding constructor |
|
|
|
|
* @see Class#getMethod |
|
|
|
|
* @see Class#getConstructor |
|
|
|
|
*/ |
|
|
|
|
public static boolean hasConstructor(Class<?> clazz, Class<?>... paramTypes) { |
|
|
|
|
return (getConstructorIfAvailable(clazz, paramTypes) != null); |
|
|
|
|