Java Collection Contain containsAtLeastOne(Collection origin, Collection elements)

Here you can find the source of containsAtLeastOne(Collection origin, Collection elements)

Description

Return true if origin collection contains at least one element from another collection

License

LGPL

Parameter

Parameter Description
origin - origin collection
elements - another collection

Declaration

public static boolean containsAtLeastOne(Collection origin, Collection elements) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.*;

public class Main {
    /** Return true if origin collection contains at least one element from another collection
     * @param origin - origin collection
     * @param elements - another collection
     *///from  w ww.  ja v a 2s. c om
    public static boolean containsAtLeastOne(Collection origin, Collection elements) {
        boolean result = false;
        for (Object element : elements) {
            if (origin.contains(element)) {
                result = true;
                break;
            }
        }

        return result;
    }
}

Related

  1. containsAnyIgnoreCase(String string, Collection searchStrings)
  2. containsAnyNull(Collection source)
  3. containsAnyOf(String s, Collection values)
  4. containsAnyVariables(Collection propertyValues)
  5. containsAssignableClass( Collection> clses, Class clazz)
  6. containsAtleastOne(Collection left, Collection right)
  7. containsByClassName(Collection objects, String className)
  8. containsByIdentity(Collection collection, Object toBeFound)
  9. containsClassOrSuper(Collection classNames, String className)