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 emptyOrNull(Collection<?> values) {
    return values == null || values.isEmpty();
}

From source file:Main.java

/**
 * Check if the given Collection is null or empty
 * /*w w  w .  j a  va 2 s  .  com*/
 * @param col
 * @return true if it is empty or null, otherwise false
 */
public static boolean isEmpty(Collection<?> col) {
    return (col == null) || col.isEmpty();
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static <T, C extends Collection<T>> List<T> merge(Collection<C> splits) {
    if (splits == null || splits.isEmpty()) {
        return Collections.emptyList();
    }//from   w ww  . j  a  va  2  s.c  o  m
    List<T> list = new ArrayList<>();
    for (Collection<T> split : splits) {
        list.addAll(split);
    }
    return list;
}

From source file:Main.java

public static boolean isNullOrEmpty(Collection<?> col) {
    return col == null || col.isEmpty();
}

From source file:Main.java

/**
 * Return the first element of the collection.
 *
 * @param collection The collection./*from   www . j av a  2s . co  m*/
 * @param <T>        The objects stored in the collection.
 *
 * @return The first element of the collection or null if the collection is empty.
 */
public static <T> T first(Collection<T> collection) {
    if (collection.isEmpty()) {
        return null;
    }

    return collection.iterator().next();
}

From source file:Main.java

public static <V> List<V> getOddIndexedValuesFrom(Collection<V> arg) {
    if (null == arg || arg.isEmpty()) {
        return Collections.EMPTY_LIST;
    }/*  w  ww.j a va 2s  .  c o m*/
    return getIndexedValuesFrom(arg, 1);
}

From source file:Main.java

public static boolean isNotEmpty(Collection collection) {
    return ((collection != null) && !(collection.isEmpty()));
}