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:com.weibo.wesync.notify.xml.DomUtils.java

/** Matches the given node's name and local name against the given desired names. */
private static boolean nodeNameMatch(Node node, Collection desiredNames) {
    return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName()));
}

From source file:Main.java

public static boolean containsAll(Collection<?> collectionToCheck, Collection<?> items) {
    for (Object o : items) {
        if (!collectionToCheck.contains(o)) {
            return false;
        }/*from   w ww  . ja va 2s  . c  o m*/
    }
    return true;
}

From source file:Main.java

private static void _addSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result,
        boolean addClassItself) {
    if (cls != endBefore && cls != null && cls != Object.class) {
        if (addClassItself) {
            if (!result.contains(cls)) {
                result.add(cls);// ww  w .  jav a  2  s  . co  m
            } else {
                return;
            }
        }
        for (Class<?> intCls : cls.getInterfaces()) {
            _addSuperTypes(intCls, endBefore, result, true);
        }
        _addSuperTypes(cls.getSuperclass(), endBefore, result, true);
    }
}

From source file:gov.nih.nci.cabig.ctms.web.taglibs.Functions.java

public static Boolean contains(Collection<?> collection, Object obj) {
    return collection == null ? Boolean.FALSE : collection.contains(obj);
}

From source file:Main.java

/**
 * Adds all objects into the specified list.
 *
 * @param collection list to fill/*from   w w  w. j  ava  2 s.c o m*/
 * @param objects    objects
 * @param <T>        objects type
 * @return true if list changed as the result of this operation, false otherwise
 */
public static <T> boolean addAll(final Collection<T> collection, final T... objects) {
    boolean result = false;
    for (final T object : objects) {
        if (!collection.contains(object)) {
            result |= collection.add(object);
        }
    }
    return result;
}

From source file:net.sf.morph.util.ContainerUtils.java

/**
 * Determines if the given <code>collection</code> contains the given
 * <code>value</code>.//from w  w w  .  j  a va2s .com
 *
 * @param collection
 *            the collection to test
 * @param value
 *            the value to test
 * @return <code>true</code> if the given collection contains the given value
 *         or <br>
 *         <code>false</code>, otherwise
 */
public static boolean contains(Collection collection, Object value) {
    return collection != null && collection.contains(value);
}

From source file:Main.java

public static <ELEMENTTYPE> boolean contains(@Nullable final Collection<? extends ELEMENTTYPE> aCollection,
        @Nullable final ELEMENTTYPE aSearch) {
    if (isEmpty(aCollection))
        return false;

    return aCollection.contains(aSearch);
}

From source file:com.tdclighthouse.prototype.utils.TdcUtils.java

public static boolean collectionContains(@SuppressWarnings("rawtypes") Collection collection, Object object) {
    return collection.contains(object);
}

From source file:Main.java

/**
 * @return true if collection is not null and contains the items
 */// w  w w  .  j  a  v a  2s .c o  m
public static boolean containsAny(final Collection<?> collection, final Object... items) {
    if (collection != null) {
        for (final Object item : items) {
            final boolean b = collection.contains(item);
            if (b) {
                return true;
            }
        }
    }
    return false;
}

From source file:Main.java

/**
 * Subtract objects in collection b from collection a. The string value
 * of the object is used for comparisons.
 * /* www .  j a  v a  2 s  .  c o  m*/
 * @param a a collection that will have members removed
 * @param b a collection whose objects will be removed from a
 * @return a new collection that contains the remaining objects in a
 */
public static Collection subtractByString(Collection a, Collection b) {
    Collection retColl = new ArrayList();
    Object obj = null;
    Iterator it = a.iterator();
    while (it.hasNext()) {
        obj = it.next();
        if (!b.contains(obj)) {
            retColl.add(obj);
        }
    }
    return retColl;
}