Java Collection Empty isNotEmpty(final Collection collection)

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

Description

Returns true if the collection is both not null and not empty; false otherwise.

License

Apache License

Parameter

Parameter Description
collection the collection to be tested.

Return

true if the collection is both not null and not empty; false otherwise.

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    /**//from w ww .ja va 2s  . c  om
     * Returns true if the collection is both not null and not empty; false
     * otherwise.
     * 
     * @param collection
     *            the collection to be tested.
     * @return true if the collection is both not null and not empty; false
     *         otherwise.
     */
    public static boolean isNotEmpty(final Collection<?> collection) {

        return !isEmpty(collection);
    }

    /**
     * Returns true if the collection is null or empty; false otherwise.
     * 
     * @param collection
     *            the collection to be tested.
     * @return true if the collection is null or empty; false otherwise.
     */
    public static boolean isEmpty(final Collection<?> collection) {

        return collection == null || collection.isEmpty();
    }
}

Related

  1. isNotEmpty(Collection values)
  2. isNotEmpty(E collection)
  3. isNotEmpty(final Collection coll)
  4. isNotEmpty(final Collection collection)
  5. isNotEmpty(final Collection collection)
  6. isNotEmpty(final Collection c)
  7. isNotEmpty(T collection, String exceptionMessage)
  8. isNotEmptyCollection(Collection collection)
  9. isNotEmptyCollection(Object[] objs)