@@ -65,6 +65,9 @@ public abstract class ClassUtils {
6565/** Prefix for internal non-primitive array class names: {@code "[L"}. */
6666private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L" ;
6767
68+ /** A reusable empty class array constant. */
69+ private static final Class <?>[] EMPTY_CLASS_ARRAY = {};
70+
6871/** The package separator character: {@code '.'}. */
6972private static final char PACKAGE_SEPARATOR = '.' ;
7073
@@ -543,17 +546,12 @@ public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) {
543546}
544547if (lhsType .isPrimitive ()) {
545548Class <?> resolvedPrimitive = primitiveWrapperTypeMap .get (rhsType );
546- if (lhsType == resolvedPrimitive ) {
547- return true ;
548- }
549+ return (lhsType == resolvedPrimitive );
549550}
550551else {
551552Class <?> resolvedWrapper = primitiveTypeToWrapperMap .get (rhsType );
552- if (resolvedWrapper != null && lhsType .isAssignableFrom (resolvedWrapper )) {
553- return true ;
554- }
553+ return (resolvedWrapper != null && lhsType .isAssignableFrom (resolvedWrapper ));
555554}
556- return false ;
557555}
558556
559557/**
@@ -681,8 +679,8 @@ public static String classNamesToString(@Nullable Collection<Class<?>> classes)
681679 * @since 3.1
682680 * @see StringUtils#toStringArray
683681 */
684- public static Class <?>[] toClassArray (Collection <Class <?>> collection ) {
685- return collection .toArray (new Class <?>[ 0 ] );
682+ public static Class <?>[] toClassArray (@ Nullable Collection <Class <?>> collection ) {
683+ return (! CollectionUtils . isEmpty ( collection ) ? collection .toArray (EMPTY_CLASS_ARRAY ) : EMPTY_CLASS_ARRAY );
686684}
687685
688686/**
@@ -1062,7 +1060,7 @@ public static String getQualifiedMethodName(Method method, @Nullable Class<?> cl
10621060 * @param clazz the clazz to analyze
10631061 * @param paramTypes the parameter types of the method
10641062 * @return whether the class has a corresponding constructor
1065- * @see Class#getMethod
1063+ * @see Class#getConstructor
10661064 */
10671065public static boolean hasConstructor (Class <?> clazz , Class <?>... paramTypes ) {
10681066return (getConstructorIfAvailable (clazz , paramTypes ) != null );
0 commit comments