Java Collection Contain containsAny(Collection list, Collection values)

Here you can find the source of containsAny(Collection list, Collection values)

Description

contains Any

License

Open Source License

Return

true if list contains any (at least 1) of the values

Declaration

public static <T> boolean containsAny(Collection<T> list, Collection<T> values) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w  ww.  j a v  a 2s .c om
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.util.Collection;

public class Main {
    /**
     * @return true if list contains any (at least 1) of the values
     */
    public static <T> boolean containsAny(Collection<T> list, Collection<T> values) {
        if (list != null) {
            for (T o : values) {
                if (list.contains(o)) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * @return true if list contains any (at least 1) of the values
     */
    public static <T> boolean containsAny(Collection<T> list, T... values) {
        if (list != null) {
            for (T o : values) {
                if (list.contains(o)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related

  1. containsAny(Collection set, Iterable elements)
  2. containsAny(Collection c, String... toCheck)
  3. containsAny(Collection strs, Collection searchTerms)
  4. containsAny(Collection collection, Collection query)
  5. containsAny(Collection collection, Collection toCheck)
  6. containsAny(Collection src, Collection containsAny)
  7. containsAny(Collection firstCollection, Collection secondCollection)
  8. containsAny(final Collection a, final Collection b)
  9. containsAny(final Collection coll1, final Collection coll2)