You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Xeno Amess <xe...@gmail.com> on 2019/06/03 16:16:29 UTC
Fwd: Is there any reasons for there being 8 ArrayUtil#isEmpty functions?
---------- Forwarded message ---------
发件人: Xeno Amess <xe...@gmail.com>
Date: 2019年6月4日周二 上午12:07
Subject: Re: Is there any reasons for there being 8 ArrayUtil#isEmpty
functions?
To: dev-subscribe@commons.apache.org <de...@commons.apache.org>
and notice that there be only one getLength function in ArrayUtils.
public static int getLength(final Object array) {
if (array == null) {
return 0;
}
return Array.getLength(array);
}
Xu Jin <xe...@gmail.com> 于2019年6月3日周一 下午11:50写道:
> // ----------------------------------------------------------------------
>
> */** * **<p>*
>
> *Checks if an array of Objects is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final Object[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive longs is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final long[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive ints is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final int[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive shorts is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final short[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive chars is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final char[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive bytes is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final byte[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive doubles is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final double[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive floats is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final float[] array) {
> return *getLength*(array) == 0;
> }
>
>
> */** * **<p>*
>
> *Checks if an array of primitive booleans is empty or {@code null}. * * @param **array *
>
>
>
> *the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */*public static boolean isEmpty(final boolean[] array) {
> return *getLength*(array) == 0;
> }
>
> I just don’t understand.
>
> Why we not using one single function like
>
>
>
> public static boolean isEmpty(Object array) {
> return *getLength*(array) == 0;
> }
>
>
>
> ?
>