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:eu.ggnet.dwoss.misc.op.listings.FtpTransfer.java

private static void deleteFilesByType(FTPClient ftp, Collection<String> fileTypesToDelete) throws IOException {
    if (fileTypesToDelete == null || fileTypesToDelete.isEmpty())
        return;//from  w  w w .  j  av a2 s  .c o m
    FTPFile[] existingFiles = ftp.listFiles();
    if (existingFiles == null || existingFiles.length == 0)
        return;
    for (String type : fileTypesToDelete) {
        for (FTPFile ftpFile : existingFiles) {
            if (ftpFile == null)
                continue;
            if (ftpFile.getName().toLowerCase().endsWith(type)) {
                if (!ftp.deleteFile(ftpFile.getName())) {
                    throw new IOException("Could not delete " + ftpFile.getName());
                }
            }
        }
    }
}

From source file:net.cloudkit.enterprises.infrastructure.utilities.Collections3Utility.java

/**
 * ?.//from w  w  w .j  av  a2 s  .  co  m
 */
public static boolean isNotEmpty(Collection<?> collection) {
    return ((collection != null) && !(collection.isEmpty()));
}

From source file:ips1ap101.lib.base.util.ColUtils.java

public static <T> Collection<T> sort(Collection<T> collection, Comparator<T> comparator) {
    if (collection instanceof List && !collection.isEmpty() && comparator != null) {
        List<T> list = (List<T>) collection;
        //          Collections.sort(list, comparator);
        wolfgangFahlSort(list, comparator);
    }//from  ww  w . j  a va  2s  .co m
    return collection;
}

From source file:net.dontdrinkandroot.utils.collections.CollectionUtils.java

public static <T extends Number> AggregationResult aggregate(final Collection<T> collection) {

    if (collection.isEmpty()) {
        throw new IllegalArgumentException("Collection must not be empty");
    }/*from w  w w .j  a  v a  2s .  c  om*/

    final AggregationResult result = new AggregationResult();
    result.setSize(collection.size());
    double sum = 0;
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;

    /* Determine min, max, sum */
    for (final T entry : collection) {
        if (entry != null) {
            final double value = entry.doubleValue();
            max = Math.max(max, value);
            min = Math.min(min, value);
            sum += value;
        }
    }
    result.setMin(min);
    result.setMax(max);
    result.setSum(sum);

    result.setAvg(sum / result.getSize());

    result.setMean(CollectionUtils.getMean(collection));

    return result;
}

From source file:cc.sion.core.utils.Collections3.java

/**
 * ?./* ww w  . j a v a 2  s .  co  m*/
 */
public static boolean isEmpty(Collection collection) {
    return (collection == null) || collection.isEmpty();
}

From source file:com.cnksi.core.tools.utils.Collections3.java

/**
 * ?.//w  w  w  . j  a  v a  2 s . c om
 */
public static boolean isEmpty(Collection collection) {

    return (collection == null || collection.isEmpty());
}

From source file:cc.sion.core.utils.Collections3.java

/**
 * ?./*from   ww  w  .  j  a v  a2 s.  co m*/
 */
public static boolean isNotEmpty(Collection collection) {
    return (collection != null) && !(collection.isEmpty());
}

From source file:org.cloudfoundry.maven.common.CommonUtils.java

/**
 * Convert a List of CloudServices to a comma delimited String using their names.
 *
 * @param list//w  w w.  j a va  2s. co m
 * @return Returns the List as a comma delimited String. Returns an empty
 *         String for a Null or empty list.
 */
public static String collectionServicesToCommaDelimitedString(Collection<? extends CloudService> list) {
    if (list == null || list.isEmpty()) {
        return "";
    }

    List<String> sb = new ArrayList<String>();

    for (CloudService service : list) {
        sb.add(service.getName());
    }

    return sb.toString();
}

From source file:com.cnksi.core.tools.utils.Collections3.java

/**
 * ?./*from w  w w  . ja  va  2s .  c  o  m*/
 */
public static boolean isNotEmpty(Collection collection) {

    return (collection != null && !(collection.isEmpty()));
}

From source file:ips1ap101.lib.base.util.ColUtils.java

@SuppressWarnings("unchecked") // unchecked cast
public static <T> Collection<T> sort(Collection<T> collection, Comparator<T>... comparators) {
    if (collection instanceof List && !collection.isEmpty() && comparators != null) {
        List<T> list = (List<T>) collection;
        Comparator<T> comparator = (Comparator<T>) ComparatorUtils.chainedComparator(comparators); // unchecked cast
        //          Collections.sort(list, comparator);
        wolfgangFahlSort(list, comparator);
    }// ww w.  j  a  v  a 2  s.c  o  m
    return collection;
}