Here you can find the source of isEmpty(Collection
isEmpty (Collection):
checks whether the collection is empty (either null or size 0)
Parameter | Description |
---|---|
objectCollection | collections needed checking |
public static boolean isEmpty(Collection<Object> objectCollection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.List; public class Main { /**/* w w w . j a v a2 s .c om*/ * <code>isEmpty (String):</code> check whether the String input is null or just blank * @param text a String text * @return true if empty, false otherwise */ public static boolean isEmpty(String text) { if ((text == null) || text.trim().equalsIgnoreCase("")) { return true; } return false; } /** * <code>isEmpty (List<String>):</code> check whether a list of string is null or either * one of the list value is blank * @param textList List<String> lines * @return true if empty, false otherwise */ public static boolean isEmpty(List<String> textList) { if (textList == null) { return true; } for (String s : textList) { if (isEmpty(s)) return true; } return false; } /** * <code>isEmpty (Collection):</code> checks whether the collection is empty (either null or size 0) * @param objectCollection collections needed checking * @return true if the collection has at least 1 element, false otherwise */ public static boolean isEmpty(Collection<Object> objectCollection) { if ((objectCollection == null) || (objectCollection.size() == 0)) return true; return false; } /** * <code>isEmpty (object array):</code> checks whether the object array is empty (either null or size 0) * @param objArray Object array to be compared * @return true if the array has at least 1 element, false otherwise */ public static boolean isEmpty(Object[] objArray) { if ((objArray == null) || (objArray.length == 0)) return true; return false; } }