Skip to content

Commit 565d026

Browse files
committed
Reuse ArrayUtils.setAll()
Javadoc
1 parent bdbc6cb commit 565d026

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/main/java/org/apache/commons/lang3/ClassUtils.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,8 +1501,8 @@ private static String toCanonicalName(final String className) {
15011501
}
15021502

15031503
/**
1504-
* Converts an array of {@link Object} in to an array of {@link Class} objects. If any of these objects is null, a null
1505-
* element will be inserted into the array.
1504+
* Converts an array of {@link Object} in to an array of {@link Class} objects. If any of these objects is null, a null element will be inserted into the
1505+
* array.
15061506
*
15071507
* <p>
15081508
* This method returns {@code null} for a {@code null} input array.
@@ -1519,9 +1519,7 @@ public static Class<?>[] toClass(final Object... array) {
15191519
if (array.length == 0) {
15201520
return ArrayUtils.EMPTY_CLASS_ARRAY;
15211521
}
1522-
final Class<?>[] classes = new Class[array.length];
1523-
Arrays.setAll(classes, i -> array[i] == null ? null : array[i].getClass());
1524-
return classes;
1522+
return ArrayUtils.setAll(new Class[array.length], i -> array[i] == null ? null : array[i].getClass());
15251523
}
15261524

15271525
/**
@@ -1557,8 +1555,8 @@ private static boolean useFull(final int runAheadTarget, final int source, final
15571555
* </p>
15581556
*
15591557
* @param classes the class array to convert, may be null or empty
1560-
* @return an array which contains for each given class, the primitive class or <strong>null</strong> if the original class is not
1561-
* a wrapper class. {@code null} if null input. Empty array if an empty array passed in.
1558+
* @return an array which contains for each given class, the primitive class or <strong>null</strong> if the original class is not a wrapper class.
1559+
* {@code null} if null input. Empty array if an empty array passed in.
15621560
* @see #wrapperToPrimitive(Class)
15631561
* @since 2.4
15641562
*/
@@ -1569,9 +1567,7 @@ public static Class<?>[] wrappersToPrimitives(final Class<?>... classes) {
15691567
if (classes.length == 0) {
15701568
return classes;
15711569
}
1572-
final Class<?>[] convertedClasses = new Class[classes.length];
1573-
Arrays.setAll(convertedClasses, i -> wrapperToPrimitive(classes[i]));
1574-
return convertedClasses;
1570+
return ArrayUtils.setAll(new Class[classes.length], i -> wrapperToPrimitive(classes[i]));
15751571
}
15761572

15771573
/**

0 commit comments

Comments
 (0)