Java List Null Empty isNotEmpty(List list)

Here you can find the source of isNotEmpty(List list)

Description

This method checks if the list is not null and have elements.

License

Open Source License

Parameter

Parameter Description
E a parameter
list the list to check

Return

true/false

Declaration

public static <E> boolean isNotEmpty(List<E> list) 

Method Source Code

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

import java.util.List;
import java.util.Set;

public class Main {
    /**//  www.java 2  s  . co m
     * Check if set isn't empty.
     * 
     * @param set
     *          The set to be tested.
     * @return <code>true</code> is not empty, <code>false</code> otherwise.
     */
    public static <E> boolean isNotEmpty(Set<E> set) {
        return set != null && !set.isEmpty();
    }

    /**
     * This method checks if the list is not null and have elements.
     * 
     * @param <E>
     * 
     * @param list
     *          the list to check
     * @return true/false
     */
    public static <E> boolean isNotEmpty(List<E> list) {
        return list != null && !list.isEmpty();
    }

    /**
     * This method checks if the list is not null and have elements.
     * 
     * @param <E>
     * 
     * @param list
     *          the list to check
     * @return true/false
     */
    public static <E> boolean isNotEmpty(E[] list) {
        return list != null && list.length > 0;
    }

    /**
     * Check if set is empty.
     * 
     * @param set
     * @return
     */
    public static <E> boolean isEmpty(Set<E> set) {
        return !isNotEmpty(set);
    }

    public static <E> boolean isEmpty(List<E> list) {
        return !isNotEmpty(list);
    }

    public static <E> boolean isEmpty(E[] list) {
        return !isNotEmpty(list);
    }
}

Related

  1. isNotEmpty(List values)
  2. isNotEmpty(List input)
  3. isNotEmpty(List input)
  4. isNotEmpty(List list)
  5. isNotEmpty(List value)
  6. isNotEmpty(List list)
  7. isNotEmpty(List list)
  8. isNotEmpty(List objList)
  9. isNotNullAndEmpty(List list)