Here you can find the source of isNullOrEmpty(Collection> col)
Parameter | Description |
---|---|
col | a parameter |
public static boolean isNullOrEmpty(Collection<?> col)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { /**//from w w w . ja va 2 s . c o m * Performs a thorough null and empty check. This asserts that a given collection is null, empty or only consists of null values. * * @param col * @return asserts that a given collection is null, empty or only consists of null values. */ public static boolean isNullOrEmpty(Collection<?> col) { if ((col == null) || col.isEmpty()) return true; else { try { for (Iterator<?> iterator = col.iterator(); iterator.hasNext();) { if (iterator.next() != null) { return false; } } } catch (NullPointerException e) { // guard against null during concurrent modifications return false; } return true; } } }