/** * Indicates whether the given array is {@code null} or empty. * * @param <T> the type of elements of the array. * @param array the array to check. * @return {@code true} if the given array is {@code null} or empty, otherwise {@code false}. */ public static <T> boolean isNullOrEmpty(T[] array) { return array == null || !hasElements(array); }
/** * Returns {@code true} if the given array has only {@code null} elements, {@code false} otherwise. If given array is * empty, this method returns {@code true}. * * @param <T> the type of elements of the array. * @param array the given array. <b>It must not be null</b>. * @return {@code true} if the given array has only {@code null} elements or is empty, {@code false} otherwise. * @throws NullPointerException if the given array is {@code null}. * @since 1.1.3 */ public static <T> boolean hasOnlyNullElements(T[] array) { checkNotNull(array); if (!hasElements(array)) { return false; } for (T o : array) { if (o != null) { return false; } } return true; }