List of utility methods to do Collection Contain
boolean | containsAtleastOne(Collection 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; |
boolean | containsByClassName(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; |
boolean | containsByIdentity(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; |
boolean | containsClassOrSuper(Collection 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; ... |
boolean | containsElement(Collection contains Element if (elem == null || isEmpty(collect)) { return false; return collect.contains(elem); |
boolean | containsIdentity(Collection extends T> collection, T element) contains Identity for (T e : collection) if (e == element) return true; return false; |
boolean | containsIdentity(Collection> objects, Object object) Returns true if objects contains object. for (Object candidate : objects) if (candidate == object) return true; return false; |
boolean | containsIgnoreCase(Collection contains Ignore Case if (c == null || s == null) { return false; for (String string : c) { if (string.equalsIgnoreCase(s)) { return true; return false; |
boolean | containsIgnoreCase(Collection Convenience method: a case-insensitive variant of Collection.contains for (String squote : c) { if (squote.equalsIgnoreCase(s)) return true; return false; |
boolean | containsIgnoreCase(Collection contains Ignore Case Iterator<String> it = c.iterator(); while (it.hasNext()) { String temp = it.next(); if (temp.equalsIgnoreCase(str)) { return true; return false; ... |