Java Utililty Methods Collection Equal

List of utility methods to do Collection Equal

Description

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

Method

booleanequal(Collection i1, Collection i2)
Equal.
if (i1 == i2)
    return true;
if (null == i1 || null == i2)
    return i1 == i2;
if (i1.size() != i2.size())
    return false;
final Iterator it1 = i1.iterator();
final Iterator it2 = i2.iterator();
...
booleanequal(Collection col1, Collection col2)
Compares the given collections.
int check = trivialCollectionEqual(col1, col2);
switch (check) {
case -1:
    return false;
case 1:
    return true;
default:
boolean contains;
for (Object eObj : col1) {
    contains = false;
    for (Object aObj : col2) {
        if (eObj.equals(aObj)) {
            contains = true;
            break;
    if (!contains) {
        return false;
return true;
booleanequalCollection(Collection c1, Collection c2)
equal Collection
return c1.containsAll(c2) && c2.containsAll(c1);
booleanequalContent(Collection col1, Collection col2)
equal Content
boolean equal = col1.size() == col2.size();
if (equal) {
    for (T val : col1) {
        equal = col2.contains(val);
        if (!equal) {
            break;
    if (equal) {
        for (T val : col2) {
            equal = col1.contains(val);
            if (!equal) {
                break;
return equal;
booleanequalContent(final Collection a, final Collection b)
If both are null will throw an error.
if ((null == a && null != b) || (null != b && null == b))
    return false;
if (a.size() != b.size())
    return false;
for (Iterator<?> ia = a.iterator(), ib = b.iterator(); ia.hasNext();) {
    if (!ia.next().equals(ib.next()))
        return false;
return true;
booleanequals(Collection c1, Collection c2)

Checks whether two collections are equal.

Object[] o1 = c1.toArray();
Object[] o2 = c2.toArray();
return internalEquals(o1, o2);
booleanequals(Collection collection1, Collection collection2)
equals
if (collection1 == collection2) {
    return true;
if (collection1.size() != collection2.size()) {
    return false;
final Iterator<?> iterator1 = collection1.iterator();
final Iterator<?> iterator2 = collection2.iterator();
...
booleanequals(Collection collection1, Collection collection2)
equals
return (collection1.containsAll(collection2) && collection2.size() == collection1.size());
booleanequals(Collection a, Collection b, boolean ordered)
equals
if (a == null)
    return b == null;
else if (b == null)
    return a == null;
else if (a.size() != b.size())
    return false;
else if (ordered)
    return a.equals(b);
...
booleanequals(final Collection c1, final Collection c2)
true if for each a in c1, a exists in c2, and if for each b in c2, b exist in c1 and c1 and c2 are the same size.
if (c1 == null || c2 == null) {
    return c1 == c2;
if (c1.size() != c2.size()) {
    return false;
if (c1 == c2) {
    return true;
...