Java Utililty Methods Collection Empty

List of utility methods to do Collection Empty

Description

The list of methods to do Collection Empty are organized into topic(s).

Method

booleannullOrEmpty(Collection c)
Indicates whether a collection is null or empty.
return null == c || c.isEmpty();
booleannullOrEmpty(final Collection in)
null Or Empty
if ((in == null) || (in.isEmpty())) {
    return true;
return false;
CollectionnullOrEmptyToDefault(final Collection collection, final Collection defaultValue)
Returns the given collection or the given default collection if the collection is null or empty
if (collection == null || collection.isEmpty()) {
    return defaultValue;
return collection;
CollectionnullToEmpty(Collection c)
Returns either c or an empty collection if c is null .
return (c == null ? (Collection<T>) Collections.emptyList() : c);
CollectionnullToEmpty(Collection coll)
null To Empty
return coll == null ? Collections.EMPTY_LIST : coll;
CollectionorEmpty(T collection)
or Empty
return (collection == null ? (Collection<V>) Collections.emptyList() : collection);
String[]removeEmptyStrings(Collection data)

Remove empty strings from a collection.

List<String> result = new ArrayList<>();
for (String element : data) {
    if (element == null || element.isEmpty()) {
        continue;
    result.add(element);
return result.toArray(new String[result.size()]);
...
booleansafeIsEmpty(Collection collection)
safe Is Empty
return collection == null || collection.isEmpty();