This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 1311d6949a2b7487766ab3c5ba86c5b9ee84d42c Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Jul 21 09:15:02 2022 -0400 Refactor some internals --- .../java/org/apache/commons/lang3/ArrayUtils.java | 50 +++++++++++++--------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index 741372499..d3f3431ef 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -1629,32 +1629,32 @@ public class ArrayUtils { } /** - * Checks if any of the objects are in the given array. + * Checks if the value is in the given array. * <p> * The method returns {@code false} if a {@code null} array is passed in. * </p> * * @param array the array to search through - * @param objectsToFind any of the objects to find - * @return {@code true} if the array contains any of the objects - * @since 3.13.0 + * @param valueToFind the value to find + * @return {@code true} if the array contains the object */ - public static boolean containsAny(final Object[] array, final Object... objectsToFind) { - return Streams.of(objectsToFind).anyMatch(e -> contains(array, e)); + public static boolean contains(final short[] array, final short valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; } /** - * Checks if the value is in the given array. + * Checks if any of the objects are in the given array. * <p> * The method returns {@code false} if a {@code null} array is passed in. * </p> * * @param array the array to search through - * @param valueToFind the value to find - * @return {@code true} if the array contains the object + * @param objectsToFind any of the objects to find + * @return {@code true} if the array contains any of the objects + * @since 3.13.0 */ - public static boolean contains(final short[] array, final short valueToFind) { - return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + public static boolean containsAny(final Object[] array, final Object... objectsToFind) { + return Streams.of(objectsToFind).anyMatch(e -> contains(array, e)); } /** @@ -3151,6 +3151,16 @@ public class ArrayUtils { return result; } + /** + * Checks if an array is empty or {@code null}. + * + * @param array the array to test + * @return {@code true} if the array is empty or {@code null} + */ + private static boolean isArrayEmpty(final Object array) { + return getLength(array) == 0; + } + /** * Returns whether a given array can safely be accessed at the given index. * @@ -3178,7 +3188,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final boolean[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3189,7 +3199,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final byte[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3200,7 +3210,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final char[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3211,7 +3221,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final double[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3222,7 +3232,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final float[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3233,7 +3243,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final int[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3244,7 +3254,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final long[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3255,7 +3265,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final Object[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /** @@ -3266,7 +3276,7 @@ public class ArrayUtils { * @since 2.1 */ public static boolean isEmpty(final short[] array) { - return getLength(array) == 0; + return isArrayEmpty(array); } /**