List of usage examples for java.util Collection isEmpty
boolean isEmpty();
From source file:Main.java
public final static boolean isAnyStringEmpty(Collection<String> collection) { if (collection == null || collection.isEmpty()) return false; for (String elem : collection) { if (TextUtils.isEmpty(elem)) return true; }/* w w w .ja v a 2 s . c o m*/ return false; }
From source file:Main.java
public final static boolean isCollectionEmpty(Collection<?> c) { boolean result = true; if (c != null && !c.isEmpty()) { result = false;//w ww.j a va 2 s .com } return result; }
From source file:Main.java
/** * Joins the elements in an input collection using a given separator. * * @param <A> Key type// w w w .java 2 s .com * @param collection Input collection * @param separator Separator * @return {@code String} representation of the input {@code collection} */ public static <A> String join(Collection<A> collection, String separator) { if (collection.isEmpty()) return ""; Iterator<A> it = collection.iterator(); StringBuilder out = new StringBuilder(); out.append(it.next()); while (it.hasNext()) out.append(separator).append(it.next()); return out.toString(); }
From source file:Main.java
/** * * @param container the containing collection * @param contained the collection with a contained element * @return true if container contains any of the elements in contained. * this is the same as asking if the collections intersect. * the terminology is just because it's sometimes easier to think of it this way. */// w w w . java2 s . co m public static boolean containsAny(Collection container, Collection contained) { Collection copy = intersect(container, contained); return !copy.isEmpty(); }
From source file:Main.java
public static <T> void addIfNotEmpty(Collection<T> c, Collection<T> elements) { if (null != c && null != elements && !elements.isEmpty()) { c.addAll(elements);/*from ww w . j a v a 2 s.c o m*/ } }
From source file:Main.java
public static boolean isEmpty(Collection<? extends Object> list) { return list == null || list.isEmpty(); }
From source file:Main.java
/** * Check whether collection is not null and not empty. * * @param collection the collection to check. * @return true if collection isn't null and not empty. *//*from w w w.j a va 2 s .co m*/ public static boolean isNotEmpty(Collection<?> collection) { return (collection != null && !collection.isEmpty()); }
From source file:Main.java
/** * Check if a collection is empty or <code>null</code>. * * @param <T>//ww w . j a v a2 s. c o m * collection element type * @param collection * a collection * @return <code>true</code> if and only if the collection is <code>null</code> or * empty */ public static <T> boolean isEmpty(final Collection<T> collection) { return ((collection == null) || collection.isEmpty()); }
From source file:Main.java
/** * Checks whether a collection is empty or null.<p> * //from w w w . j a v a2 s .co m * @param collection a collection * @return true if <code>collection</code> is <code>null</code> or empty. */ public static boolean isEmptyOrNull(Collection<?> collection) { return (collection == null) || collection.isEmpty(); }
From source file:Main.java
public static final <T> boolean isNullOrEmpty(Collection<T> collection) { if (collection == null || collection.isEmpty()) { return true; }/*from ww w . ja va 2s . co m*/ for (T item : collection) { if (item != null) { return false; } } return true; }