List of usage examples for java.util Collection isEmpty
boolean isEmpty();
From source file:Main.java
public static boolean isNull(Collection<?> con) { if (con == null || con.isEmpty()) { return true; }/*from ww w . j a v a2 s . com*/ return false; }
From source file:Main.java
/** * Null-safe check if the specified collection is empty. * * @param collection//w ww .j av a2 s .c o m * the collection to check * @return true if empty or null */ public static boolean isEmpty(final Collection<?> collection) { return collection == null || collection.isEmpty(); }
From source file:Main.java
public static boolean isEmpty(Collection c) { if (c == null) { return true; }/*from w ww . jav a 2 s . c om*/ return c.isEmpty(); }
From source file:Main.java
public static <T> List<T> subCollection(Collection<T> collection, int start, int end) { if (null == collection || collection.isEmpty()) return null; int count = 0; List<T> result = new ArrayList<T>(); for (T item : collection) { if (start >= count && count < end) { result.add(item);//from w w w.j ava 2 s . c o m } count++; } return result; }
From source file:Main.java
public static boolean isNotEmpty(Collection<?> collection) { return !(collection == null || collection.isEmpty()); }
From source file:Main.java
/** * Provides a wrapper to create a list out of a collection * @param wrappedCollection nullable collection * @param <T> type parameter of collection and resulting list * @return list of Ts from wrappedCollection or empty list *//*from w w w .jav a 2s. com*/ @Nonnull public static <T> List<T> listFrom(@Nullable Collection<T> wrappedCollection) { if (wrappedCollection == null || wrappedCollection.isEmpty()) { return new ArrayList<T>(); } else { return new ArrayList<T>(wrappedCollection); } }
From source file:Main.java
/** * Return <code>true</code> if the supplied Collection is <code>null</code> or empty. Otherwise, return <code>false</code>. * /*from w w w.j av a 2 s . c o m*/ * @param collection * the Collection to check * @return whether the given Collection is empty */ public static boolean isEmpty(Collection<?> collection) { return ((collection == null) || collection.isEmpty()); }
From source file:Main.java
/** * Indique si une collection est null ou vide. * * @param c//from w ww.j av a 2 s . c o m * @return boolean */ public static boolean isNullOrEmpty(Collection c) { if (c == null) { return true; } return c.isEmpty(); }
From source file:Main.java
public static boolean isEmpty(final Collection<?> collection) { return collection == null || collection.isEmpty(); }
From source file:Main.java
public static <T> T last(Collection<T> collection) { if (collection == null || collection.isEmpty()) { return null; }/*from ww w . j ava2 s . com*/ Iterator<T> iterator = collection.iterator(); T elem = null; while (iterator.hasNext()) { elem = iterator.next(); } return elem; }