Example usage for java.util Collection contains

List of usage examples for java.util Collection contains

Introduction

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

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this collection contains the specified element.

Usage

From source file:Main.java

public static boolean contains(Collection col, Object obj) {
    return ((obj != null && col != null) ? col.contains(obj) : false);
}

From source file:Main.java

public static String suggest(Collection c, String prefix) {
    int i = 1;//www .j  a v  a  2  s  .  c o m
    while (c.contains(prefix + i))
        i++;
    return prefix + i;
}

From source file:Main.java

public static <T> boolean isSubsetOf(Collection<T> subset, Collection<T> superSet) {
    for (T t : subset) {
        if (!superSet.contains(t)) {
            return false;
        }/*  w ww.  j  a v  a 2  s .  co  m*/
    }
    return true;
}

From source file:Main.java

public static boolean isSubset(Collection<?> subset, Collection<?> of) {
    for (Object obj : subset) {
        if (!of.contains(obj)) {
            return false;
        }/*from w  ww  . j  a v a2  s.  c om*/
    }

    return true;
}

From source file:com.creditcloud.common.taglib.Functions.java

/**
 * ????//from   w w w . j av a  2 s .c  om
 * 
 * @param all
 * @param item
 * @return 
 */
public static boolean contains(Collection all, Object item) {
    return all.contains(item);
}

From source file:Main.java

public static <T> Collection<T> merge(Collection<T> c1, Collection<T> c2) {
    for (T e : c2) {
        if (!c1.contains(e)) {
            c1.add(e);//from w w  w.ja va 2 s.com
        }
    }
    return c1;
}

From source file:Main.java

public static <T> void addIfNotNullNotExist(Collection<T> col, T val) {
    if (val != null && !col.contains(val)) {
        col.add(val);
    }/* ww w  .jav a2  s .c  o  m*/
}

From source file:Main.java

public static boolean containsAny(Collection all, Collection keys) {
    for (Object key : keys) {
        if (all.contains(key)) {
            return true;
        }//  w  ww .  j  a  va  2  s  .  c o m
    }
    return false;
}

From source file:Main.java

public static <E> boolean includedElements(Collection<E> c1, Collection<E> c2) {
    for (E e : c1) {
        if (!c2.contains(e))
            return false;
    }/*  w  w  w.j  av a  2  s . c o m*/

    return true;
}

From source file:Main.java

final static public boolean contains(Collection collection, Object item) {
    return collection != null && collection.contains(item);
}