Java Collection Empty isNullOrEmpty(Collection coll)

Here you can find the source of isNullOrEmpty(Collection coll)

Description

This method is used to check for the null or empty Collection

License

Open Source License

Parameter

Parameter Description
coll Collection to be checked.

Return

value true if is null or size is zero, else returns false

Declaration


@SuppressWarnings("rawtypes")
public static boolean isNullOrEmpty(Collection coll) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Map;

public class Main {
    /**/*from  w w  w  . j a v a2  s  .c  o  m*/
     * This method is used to check for the null or empty parameters in string
     * array
     * 
     * @param params
     *            {@link String} array of parameters to be checked.
     * @return {@link Boolean} value false if parameters not null and true if
     *         even one parameter is null or empty
     */

    public static boolean isNullOrEmpty(String[] params) {

        // Check for null and empty
        for (String item : params) {

            if (item == null || item.equals("null") || item.trim().length() == 0)
                return true;
        }
        return false;
    }

    /**
     * This method is used to check for the null or empty {@link Collection}
     * 
     * @param coll
     *            {@link Collection} to be checked.
     * @return {@link Boolean} value true if {@link Collection} is null or size
     *         is zero, else returns false
     */

    @SuppressWarnings("rawtypes")
    public static boolean isNullOrEmpty(Collection coll) {

        if (coll == null || coll.size() == 0)
            return true;

        return false;
    }

    /**
     * This method is used to check for the null or empty {@link Map}
     * 
     * @param map
     *            {@link Map} to be checked.
     * @return {@link Boolean} value true if {@link Map} is null or size is
     *         zero, else returns false
     */

    @SuppressWarnings("rawtypes")
    public static boolean isNullOrEmpty(Map map) {

        if (map == null || map.size() == 0)
            return true;

        return false;
    }
}

Related

  1. isNotEmptyException(Collection collection)
  2. isNotEmptyOrNull(Collection collection)
  3. IsNotEmptyOrNull(Collection elements)
  4. isNullOrEmpty(Collection c)
  5. isNullOrEmpty(Collection c)
  6. isNullOrEmpty(Collection collection)
  7. isNullOrEmpty(Collection collection)
  8. isNullOrEmpty(Collection col)
  9. isNullOrEmpty(Collection collection)