Example usage for java.util Collection isEmpty

List of usage examples for java.util Collection isEmpty

Introduction

In this page you can find the example usage for java.util Collection isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this collection contains no elements.

Usage

From source file:Main.java

public static boolean isNotNull(Collection<?> c) {
    if (c == null || c.isEmpty()) {
        return false;
    } else {//from  w w  w.j ava 2  s.  c  om
        return true;
    }
}

From source file:Main.java

public static Object getFirstItem(Collection<?> collection) {
    return null == collection || collection.isEmpty() ? null : collection.iterator().next();
}

From source file:Main.java

public static <T> boolean isCollectionEmpty(Collection<T> collection) {
    return collection == null || collection.isEmpty();
}

From source file:Main.java

public static boolean isEmpty(Collection input) {
    return input == null || input.isEmpty();
}

From source file:Main.java

public static boolean isValid(Collection<?> coll) {
    return coll != null && !coll.isEmpty();
}

From source file:Main.java

public static <T> T getAny(Collection<T> c) {
    if (c != null && !c.isEmpty()) {
        for (T t : c) {
            return t;
        }//from w  w  w.ja  v  a 2s  . c o m
    }
    return null;
}

From source file:Main.java

public static <T> boolean notNullOrEmpty(Collection<T> c) {
    return nonNull(c) && !c.isEmpty();
}

From source file:Main.java

@SuppressWarnings("rawtypes")
public static boolean isValid(Collection col) {
    return !(col == null || col.isEmpty());
}

From source file:Main.java

public static <T> Boolean isEmpty(Collection<T> collection) {
    return collection == null || collection.isEmpty();
}

From source file:Main.java

public static <E> void intersection(final Collection<E> a, final Collection<E> b) {
    if (b != null && !b.isEmpty()) {
        if (a.isEmpty()) {
            a.addAll(b);/*from ww  w .  j  a v  a 2 s .  c om*/
        } else {
            a.retainAll(b);
        }
    }
}