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

/**
 * @param collectionOfCollection/*from ww  w  .  ja va2 s . c  o m*/
 *            a Collection<Collection<T>>
 * 
 * @return a Set<T> containing all values of all Collections<T>
 *         without any duplicates
 */
public static <T> Set<T> unionOfListOfLists(final Collection<? extends Collection<T>> collectionOfCollection) {
    if (collectionOfCollection == null || collectionOfCollection.isEmpty()) {
        return new HashSet<T>(0);
    }
    final HashSet<T> union = new HashSet<T>();
    for (final Collection<T> col : collectionOfCollection) {
        if (col != null) {
            for (final T t : col) {
                if (t != null) {
                    union.add(t);
                }
            }
        }
    }
    return union;
}

From source file:annis.sqlgen.SqlConstraints.java

public static String in(String lhs, Collection<?> values) {
    if (values.isEmpty()) {
        return in(lhs, "NULL");
    } else {// w  ww  .j a  v a2  s. c o m
        return in(lhs, StringUtils.join(values, ","));
    }
}

From source file:com.nwtx.manager.common.utils.Collections3.java

/**
 * ?./*  w  ww  .  j a  va2s  .c  o m*/
 */
public static boolean isEmpty(Collection<?> collection) {
    return (collection == null) || collection.isEmpty();
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.util.MetaSanitizerUtil.java

/**
 * Takes a List of keyword Strings and returns a comma separated list of keywords as String.
 *
 * @param keywords//from w ww  .  j  a  v  a 2  s.c om
 *           List of KeywordModel objects
 * @return String of comma separated keywords
 */
public static String sanitizeKeywords(final Collection<String> keywords) {
    if (keywords != null && !keywords.isEmpty()) {
        // Remove duplicates
        final Set<String> keywordSet = new HashSet<String>(keywords);

        // Format keywords, join with comma
        final StringBuilder stringBuilder = new StringBuilder();
        for (final String keyword : keywordSet) {
            stringBuilder.append(keyword).append(',');
        }
        if (stringBuilder.length() > 0) {
            // Remove last comma
            return stringBuilder.substring(0, stringBuilder.length() - 1);
        }
    }
    return "";
}

From source file:com.nwtx.manager.common.utils.Collections3.java

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

From source file:com.streamsets.pipeline.stage.destination.mapreduce.MapreduceUtils.java

private static void appendJars(Configuration conf, Collection<String> appendJars) {
    if (appendJars.isEmpty()) {
        return;// w w  w  .  ja v a2  s .  com
    }

    String addition = StringUtils.join(appendJars, JAR_SEPARATOR);

    // Get previously configured jars (if any)
    String tmpjars = conf.get(TMP_JARS_PROPERTY);
    tmpjars = StringUtils.isEmpty(tmpjars) ? addition : tmpjars + JAR_SEPARATOR + addition;

    conf.set(TMP_JARS_PROPERTY, tmpjars);
}

From source file:adalid.commons.util.ColUtils.java

public static <T> Collection<T> filter(Collection<T> collection, Predicate predicate) {
    if (collection == null || collection.isEmpty() || predicate == null) {
        return collection;
    } else {//from   w  w w. j  a  v a2s  . c  om
        //          Collection<T> list = new ArrayList<T>();
        //          list.addAll(collection);
        Collection<T> list = new ArrayList<>(collection);
        CollectionUtils.filter(list, predicate);
        return list;
    }
}

From source file:de.tu_berlin.dima.oligos.db.DbUtils.java

public static DenseSchema sparseToDenseSchema(SparseSchema sparseSchema, JdbcConnector connector)
        throws SQLException {
    DenseSchema denseSchema = new DenseSchema();
    for (String schema : sparseSchema.schemas()) {
        Collection<String> tables = sparseSchema.tablesIn(schema);
        if (tables.isEmpty()) {
            tables = connector.getTables(schema);
        }/*from ww  w.  j a  v a  2  s.  c  o m*/
        for (String table : tables) {
            Collection<String> columns = sparseSchema.columnsIn(schema, table);
            if (columns.isEmpty()) {
                columns = connector.getColumns(schema, table);
            }
            for (String column : columns) {
                denseSchema.addColumn(new ColumnId(schema, table, column));
            }
        }
    }
    return denseSchema;
}

From source file:adalid.commons.util.ColUtils.java

public static <T> Collection<T> allFilter(Collection<T> collection, Predicate... predicates) {
    if (collection == null || collection.isEmpty() || predicates == null) {
        return collection;
    } else {/*from  ww  w .  ja v  a 2  s  . c  o  m*/
        //          Collection<T> list = new ArrayList<T>();
        //          list.addAll(collection);
        Collection<T> list = new ArrayList<>(collection);
        Predicate predicate = PredicateUtils.allPredicate(predicates);
        CollectionUtils.filter(list, predicate);
        return list;
    }
}

From source file:adalid.commons.util.ColUtils.java

public static <T> Collection<T> anyFilter(Collection<T> collection, Predicate... predicates) {
    if (collection == null || collection.isEmpty() || predicates == null) {
        return collection;
    } else {/* ww  w  . j a  v  a 2s .  com*/
        //          Collection<T> list = new ArrayList<T>();
        //          list.addAll(collection);
        Collection<T> list = new ArrayList<>(collection);
        Predicate predicate = PredicateUtils.anyPredicate(predicates);
        CollectionUtils.filter(list, predicate);
        return list;
    }
}