Java Utililty Methods Collection Contain

List of utility methods to do Collection Contain

Description

The list of methods to do Collection Contain are organized into topic(s).

Method

booleancontainsAtleastOne(Collection left, Collection right)
Checks if right hand collection has atleast one same item as left hand collection.
if (left == null || right == null) {
    return false;
for (S id : left) {
    if (right.contains(id)) {
        return true;
return false;
booleancontainsByClassName(Collection objects, String className)
Checks if the given collection contains an object with the given class name.
for (Object object : objects) {
    if (object.getClass().getName().equals(className)) {
        return true;
return false;
booleancontainsByIdentity(Collection collection, Object toBeFound)
Check if a collection contains a specific object by searching for it by identity instead of by using equals/hashcode.
for (Object o : collection) {
    if (o == toBeFound)
        return true;
return false;
booleancontainsClassOrSuper(Collection classNames, String className)
When working with String class names, returns true if a collection contains a given class name or the names of one superclass of the given class name.
if (classNames.contains(className)) {
    return true;
Class<?> classToCompare = Class.forName(className);
for (String name : classNames) {
    Class<?> currentClass = Class.forName(name);
    if (currentClass.isAssignableFrom(classToCompare)) {
        return true;
...
booleancontainsElement(Collection collect, T elem)
contains Element
if (elem == null || isEmpty(collect)) {
    return false;
return collect.contains(elem);
booleancontainsIdentity(Collection collection, T element)
contains Identity
for (T e : collection)
    if (e == element)
        return true;
return false;
booleancontainsIdentity(Collection objects, Object object)
Returns true if objects contains object.
for (Object candidate : objects)
    if (candidate == object)
        return true;
return false;
booleancontainsIgnoreCase(Collection c, String s)
contains Ignore Case
if (c == null || s == null) {
    return false;
for (String string : c) {
    if (string.equalsIgnoreCase(s)) {
        return true;
return false;
booleancontainsIgnoreCase(Collection c, String s)
Convenience method: a case-insensitive variant of Collection.contains
for (String squote : c) {
    if (squote.equalsIgnoreCase(s))
        return true;
return false;
booleancontainsIgnoreCase(Collection c, String str)
contains Ignore Case
Iterator<String> it = c.iterator();
while (it.hasNext()) {
    String temp = it.next();
    if (temp.equalsIgnoreCase(str)) {
        return true;
return false;
...