List of usage examples for java.util Collection isEmpty
boolean isEmpty();
From source file:Main.java
/** Returns true if all elements in the collection are the same */ public static <T> boolean allEqual(Collection<T> elements) { if (elements.isEmpty()) return false; Iterator<T> it = elements.iterator(); T first = it.next();//from w ww.j a va 2 s .c o m while (it.hasNext()) { T el = it.next(); if (!el.equals(first)) return false; } return true; }
From source file:Main.java
public static boolean isEmpty(Collection<?> target) { return target == null || target.isEmpty(); }
From source file:Main.java
public static Class<?> getTypeOfFirstElement(Collection<?> collection) { if (collection.isEmpty()) { return null; } else {/*from w ww. j a va 2s . c o m*/ return getFirstObject(collection).getClass(); } }
From source file:Main.java
/** * Null-safe check if the specified collection is empty. * <p>//from w w w. j a v a2 s . c om * Null returns true. * * @param coll the collection to check, may be null * @return true if empty or null * @since Commons Collections 3.2 */ public static boolean isEmpty(Collection coll) { return (coll == null || coll.isEmpty()); }
From source file:Main.java
public static boolean isEmpty(Collection coll) { if (coll == null || coll.isEmpty()) { return true; }/*ww w .j a va2 s . com*/ return false; }
From source file:Main.java
/** * Get the first item in a list. If there is no such item, return * null.//w ww . j a v a2 s . c o m */ public static <T> T first(Collection<T> list) { if (list == null || list.isEmpty()) return null; return list.iterator().next(); }
From source file:Main.java
public static boolean isNullOrEmpty(Collection<?> c) { return c == null || c.isEmpty(); }
From source file:Main.java
public static boolean isNotEmpty(Collection<?> coll) { return coll != null && !coll.isEmpty(); }
From source file:Main.java
/** * Checks the collection for content.//from w w w.j a v a2 s. co m * * @param coll The collection to test. * @return True if the list is null or empty, false if there is any content. */ public static boolean isNullOrEmpty(Collection<?> coll) { return coll == null || coll.isEmpty(); }
From source file:Main.java
public static boolean isEmpty(final Collection values) { return values == null || values.isEmpty(); }