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

/**
 * @return true if collection null or empty.
 *//*from  w  ww  .  jav a 2  s  .  c  o m*/
public static boolean isEmpty(final Collection<?> col) {
    return col == null || col.isEmpty();
}

From source file:Main.java

public static String join(Collection<?> items, String delimiter) {
    if (items == null || items.isEmpty()) {
        return "";
    }//  www. ja  v  a2s  . c o  m

    final Iterator<?> iter = items.iterator();
    final StringBuilder buffer = new StringBuilder(iter.next().toString());

    while (iter.hasNext()) {
        buffer.append(delimiter).append(iter.next());
    }

    return buffer.toString();
}

From source file:Main.java

/**
 * @return true if collection not empty (null safe).
 *//*from w w  w.  j a  va 2 s.co m*/
public static boolean isNotEmpty(final Collection<?> col) {
    return col != null && !col.isEmpty();
}

From source file:Main.java

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

From source file:Main.java

/**
 * Return {@code true} if the supplied Collection is {@code null}
 * or empty. Otherwise, return {@code false}.
 * @param collection the Collection to check
 * @return whether the given Collection is empty
 *///from w  ww  . j av a2 s. c  o m
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Collection collection) {
    return (collection == null || collection.isEmpty());
}

From source file:Main.java

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

From source file:Main.java

public static boolean hasAtLeastOneNotNullElement(Collection<?> collection) {
    if (collection == null)
        return false;
    if (collection.isEmpty())
        return false;
    if (collection.contains(null))
        return collection.size() > 1;
    return collection.size() > 0;
}

From source file:Main.java

public static final void distinctCollection(Collection<? extends Object> collection) {
    if (collection != null && !collection.isEmpty()) {
        Set<? extends Object> distinctSet = new HashSet<Object>(collection);

        collection.clear();//from  w  ww  . j  a v a2  s  . c om

        ((Collection<Object>) collection).addAll(distinctSet);
    }
}

From source file:Main.java

public static boolean isEmpty(@Nullable final Collection<?> aCont) {
    return aCont == null || aCont.isEmpty();
}

From source file:Main.java

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