List of utility methods to do Collection Equal
boolean | equals(Iterable> collection1, Iterable> collection2) Returns true if the elements of the two given Collection s are equal and have the same order boolean retval = false; if (collection1 != null && collection2 != null) { Iterator<?> iteratorOther = collection2.iterator(); Iterator<?> iteratorThis = collection1.iterator(); retval = true; while (iteratorOther.hasNext() && iteratorThis.hasNext()) { Object elementOther = iteratorOther.next(); Object elementThis = iteratorThis.next(); ... |
boolean | equalsAny(Object object, Collection Checks whether object equals any of objects , using the Object#equals(Object) method in object for comparisons. for (Object o : objects) { if (object == null && o == null) { return true; } else if (object != null && object.equals(o)) { return true; return false; ... |
boolean | equalsCollectionsAnyOrder(Collection> i1, Collection> i2) Check if values in iterables are identical (in any order) This method check sizes first For first collection calls Iterable#iterator() only once, and several times for second collection (max = size of collection) if (i1 == i2) { return true; if (i1 == null) { if (i2 == null) { return true; return false; ... |
Boolean | equalsNull(Collection collection) equals Null return collection == null;
|
boolean | equalsOne(final T o1, final Collection extends T> others) equals One for (final Object o : others) { if (o.equals(o1)) { return true; return false; |
boolean | equalsSet(Collection c1, Collection c2) equals Set boolean equals; if (c1 == null) { equals = (c2 == null); } else if (c2 == null) { equals = false; } else if (c1.size() == c2.size()) { equals = true; Iterator iterC1 = c1.iterator(); ... |
boolean | equalsSet(Collection c1, Collection c2) equals Set return new HashSet(c1).equals(new HashSet(c2)); |
boolean | equalsUnordered(Collection> collection1, Collection> collection2) Tests, if the two collection have the same elements. boolean retval = collection1.size() == collection2.size(); for (Object iObject : collection1) { retval &= collection2.contains(iObject); return retval; |
boolean | equalsUnordered(Collection> collection1, Collection> collection2) equals Unordered return collection1 == collection2
|| (collection1.size() == collection2.size() && collection1.containsAll(collection2));
|
boolean | equalsUnorderedCollections(Collection Compares the elements of two collections using Object.equals on the elements. if (a == b) { return true; if (a.size() != b.size()) return false; List<T> _b = new ArrayList<T>(b); for (final T elemA : a) { boolean foundMatching = false; ... |