List of utility methods to do List Contain
boolean | containsReference(List> references, Object toBeFound) contains Reference for (Object reference : references) { if (reference == toBeFound) { return true; return false; |
boolean | containsSameItemsInOrder(List> col1, List> col2) contains Same Items In Order if (col1 == col2) return true; if (col1 == null || col2 == null) return false; if (col1.size() != col2.size()) return false; Iterator<?> it1 = col1.iterator(); Iterator<?> it2 = col2.iterator(); ... |
boolean | containsStr(List contains Str for (Iterator<String> i = list.iterator(); i.hasNext();) if (((String) i.next()).equals(str)) return true; return false; |
boolean | containsStringStartingWith(List contains String Starting With for (String s : list) { if (s.startsWith(prefix)) return true; return false; |
boolean | containsSubsequence(List> a, List> b) Determines whether a given list contains another list as a subsequence. if (b.size() > a.size()) return false; outer: for (int i = 0, maxi = b.size(); i < maxi; i++) { for (int j = i, maxj = a.size(); j < maxj; j++) { if (a.get(j).equals(b.get(i))) { continue outer; return false; return true; |
boolean | containsType(List> list, Class type) contains Type return (indexOfType(list, type) != -1);
|
boolean | containsUnorderedSequence(List contains Unordered Sequence int remaining = a.size() - b.size(); for (int i = 0; i < remaining; i++) if (a.subList(i, i + b.size()).containsAll(b)) return true; return false; |
boolean | containsUsingToArray(List contains Using To Array boolean found = false; Object[] a = list.toArray(); for (int i = 0; i < a.length; ++i) { if (a[i].equals(value)) found = true; return found; |
boolean | containsWhitespace(List contains Whitespace Iterator itr = elements.iterator(); while (itr.hasNext()) { String element = (String) itr.next(); if (element.trim().equals("")) { return true; return false; ... |
String | firstFunnyString(List first Funny String String res = words.stream().map(String::toUpperCase).filter(s -> s.length() < 7)
.filter(s -> s.contains(containedTest)).findFirst().orElse(null);
return res;
|