List of usage examples for java.util Collection size
int size();
From source file:Main.java
public static boolean isEmpty(Collection<?> c) { if (c == null || c.size() == 0) { return true; }//from w w w.j a v a 2s.co m return false; }
From source file:Main.java
/** * Check if the collection is empty//w w w .j av a 2 s . c om * * @param c The collection to check. * @return False if the collection is not null and contains at least one element. True if the collection * is null, or if the collection is empty. */ public static boolean isEmpty(Collection<?> c) { if (c != null && c.size() > 0) { return false; } return true; }
From source file:Main.java
/** * This method to check if Collection is Empty * @param Collection list/*w w w. ja v a2 s . co m*/ * @return boolean */ public static boolean isEmptyList(Collection list) { if (list == null || list.size() == 0) { return true; } return false; }
From source file:Main.java
public static <E> int sizeOf(Collection<E> c) { return isEmpty(c) ? 0 : c.size(); }
From source file:Main.java
public static <T> T getSole(Collection<T> l) { return l.size() == 1 ? l.iterator().next() : null; }
From source file:Main.java
public static boolean isEmpty(final Collection<?> c) { return (c == null) || (c.size() == 0); }
From source file:Main.java
/** * * @param <T>// w w w .ja v a 2 s.c o m * @param collection * @return first element or null if empty */ public static <T> T getFirstElement(Collection<? extends T> collection) { return collection.size() > 0 ? collection.iterator().next() : null; }
From source file:Main.java
public static boolean notEmpty(Collection collection) { return collection != null && collection.size() > 0; }
From source file:Main.java
public static boolean isNullOrEmpty(Collection<?> list) { return list == null || list.size() == 0; }
From source file:Main.java
public static boolean isNotEmpty(Collection collection) { return collection != null && collection.size() > 0; }