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

CollectionemptyToNull(final Collection value)
If the given collection is empty null is returned.
return value.isEmpty() ? null : value;
CollectiongetSingletonCollectionOrEmptyIfNull(T o)
get Singleton Collection Or Empty If Null
if (o == null)
    return Collections.emptySet();
else
    return Collections.singleton(o);
booleanisAnyEmpty(Collection... collections)
is Any Empty
if (collections == null) {
    return true;
for (Collection<?> collection : collections) {
    if (isEmpty(collection)) {
        return true;
return false;
booleanisCollectionEmpty(Collection collection)
is Collection Empty
boolean isEmpty = true;
Iterator iterator = collection.iterator();
while (iterator.hasNext() && isEmpty) {
    Object object = iterator.next();
    if (object != null) {
        isEmpty = false;
return isEmpty;
BooleanisCollectionEmpty(Collection oneCol)
is Collection Empty
return (oneCol == null || oneCol.isEmpty() || oneCol.size() < 1);
booleanisCollectionEmpty(Collection value)
is Collection Empty
if (isNull(value)) {
    return true;
return value.isEmpty();
booleanisCollectionNotEmpty(Collection collection)
is Collection Not Empty
return !isCollectionEmpty(collection);
booleanisCollectionNullOrEmpty(Collection collection)
is Collection Null Or Empty
return collection == null || collection.isEmpty();
booleanisEmpty(Collection c)
Check whether collection c is empty.
return ((c == null) || (c.size() == 0));
booleanisEmpty(Collection c)
is Empty
return c == null || c.isEmpty();