Java Collection Empty isNullOrEmpty(final Collection collection)

Here you can find the source of isNullOrEmpty(final Collection collection)

Description

is Null Or Empty

License

Artistic License

Declaration

public static boolean isNullOrEmpty(final Collection<?> collection) 

Method Source Code

//package com.java2s;
/**//from  www. j a  v  a 2 s  . c o  m
 * (c) 2009-2014 Peter Wullinger
 *
 * $Id$
 *
 * Use, modification and restribution of this file are covered by the
 * terms of the Artistic License 2.0.
 *
 * You should have received a copy of the license terms in a file named
 * "LICENSE" together with this software package.
 *
 * Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
 * HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE
 * EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO
 * COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT
 * OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 **/

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static boolean isNullOrEmpty(final Iterable<?> iterable) {
        return (iterable == null) || (!iterable.iterator().hasNext());
    }

    public static boolean isNullOrEmpty(final Iterator<?> iterator) {
        return (iterator == null) || (!iterator.hasNext());
    }

    public static boolean isNullOrEmpty(final Collection<?> collection) {
        return (collection == null) || (collection.isEmpty());
    }
}

Related

  1. isNullOrEmpty(Collection list)
  2. isNullOrEmpty(Collection obj)
  3. isNullOrEmpty(Collection s)
  4. isNullOrEmpty(Collection values)
  5. isNullOrEmpty(final Collection c)
  6. isNullOrEmpty(final Collection value)
  7. isNullOrEmpty(final Collection collection)
  8. isNullOrEmpty(T collection)
  9. nullOrEmpty(Collection coll)