List of usage examples for java.util Collection isEmpty
boolean isEmpty();
From source file:Main.java
public static <T> boolean isEmpty(Collection<T> collection) { if (collection == null) { return true; }//from w w w.j av a 2s. co m return collection.isEmpty(); }
From source file:me.taylorkelly.mywarp.util.CommandUtils.java
/** * Joins all warps in the given collection in one string, separated by {@code ", "}. * * @param warps a collection of warps//ww w. j a v a 2 s. co m * @return a string with all warp-names or {@code -} if the collection was empty */ public static String joinWarps(Collection<Warp> warps) { if (warps.isEmpty()) { return "-"; } StrBuilder ret = new StrBuilder(); for (Warp warp : warps) { ret.appendSeparator(", "); ret.append(warp.getName()); } return ret.toString(); }
From source file:Main.java
public static <T> List<T> sub(Collection<T> list, int start, int end) { if (list == null || list.isEmpty()) { return new ArrayList<>(); }//from w w w . jav a2s . co m return sub(new ArrayList<T>(list), start, end); }
From source file:Main.java
/** * Check if collection is not <tt>null</tt> and empty * * @param collection/*from w w w.j ava 2 s. c o m*/ * Collection to check * * @return <tt>true</tt>, if collection is not null and empty, else * <tt>false</tt> */ public static <T> boolean isEmpty(Collection<T> collection) { return collection != null && collection.isEmpty(); }
From source file:Main.java
/** * Return <code>true</code> if the supplied Collection is <code>null</code> * or empty. Otherwise, return <code>false</code>. * * @param collection the Collection to check * @return whether the given Collection is empty */// www .java2s . c o m public static boolean isEmpty(Collection collection) { return (collection == null || collection.isEmpty()); }
From source file:Main.java
/** * Checks to see if a collection is empty * <p>/*from w w w.ja v a 2 s. c om*/ * An empty collection is one that is null or has zero elements. Everything else is * considered non-empty. * </p> * * @param collection The collection to check * @param <T> The type of the collection * @return true if the collection is null or empty, false otherwise */ public static <T> boolean isEmpty(Collection<T> collection) { return collection == null || collection.isEmpty(); }
From source file:Main.java
public static String toStringWithDelimiter(final Collection<?> collection, final String delimiter) { if ((collection == null) || collection.isEmpty()) { return ""; }//from ww w .ja va 2s . c o m final StringBuilder stringBuilder = new StringBuilder(collection.size()); int i = 0; for (final Object o : collection) { stringBuilder.append(o); ++i; if (collection.size() != i) { stringBuilder.append(delimiter); } } return stringBuilder.toString(); }
From source file:Main.java
/** * Return <code>true</code> if the supplied Collection is <code>null</code> * or empty. Otherwise, return <code>false</code>. * @param collection the Collection to check *//*from w ww . j av a2s .co m*/ @SuppressWarnings("unchecked") public static boolean isEmpty(Collection collection) { return (collection == null || collection.isEmpty()); }
From source file:Main.java
public static boolean isSameCollection(Collection<?> newCollection, Collection<?> oldCollection) { if (newCollection == null || newCollection.isEmpty()) { return true; } else if (oldCollection != null) { if (newCollection.containsAll(oldCollection) && oldCollection.containsAll(newCollection)) { return true; } else {//w w w.j av a 2 s .c om return false; } } return false; }
From source file:Main.java
public static boolean isNotEmpty(Collection<?> c) { if (c == null) { return false; }/*w w w. j ava 2s . co m*/ return !c.isEmpty(); }