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

booleanallEqual(Class[] collection, Class cls)
Returns true if all classes in the collection array are equal to cls
for (Class<?> c : collection) {
    if (c != cls) {
        return false;
return true;
booleanallEqual(final Class[] collection, final Class cls)
all Equal
for (final Class<?> c : collection) {
    if (c != cls) {
        return false;
return true;
booleanareEqual(Collection collection1, Collection collection2)
are Equal
if (collection1.size() != collection2.size())
    return false;
Iterator iterator = collection1.iterator();
while (iterator.hasNext()) {
    if (!collection2.contains(iterator.next()))
        return false;
return true;
...
booleanareEqual(Collection collection1, Collection collection2)
are Equal
if (collection1 == null && collection2 == null)
    return true;
if (collection1 == null || collection2 == null)
    return false;
if (collection1.size() != collection2.size())
    return false;
for (Object member : collection1) {
    if (!collection2.contains(member))
...
booleancompareTwoCollectionsEquality(Collection expectedAffectedFiles, Collection affectedFiles)
compare Two Collections Equality
int counter = 0;
for (String f1 : affectedFiles) {
    for (String f2 : expectedAffectedFiles) {
        if (f1.equals(f2)) {
            counter++;
return expectedAffectedFiles.size() == counter;
booleancontainsAtleastOneEqualString(Collection left, String right)
contains Atleast One Equal String
Collection<String> r = new ArrayList<String>(1);
r.add(right);
return containsAtleastOneEqualString(left, r);
intcontainsByEquals(Collection collection, Object obj)
contains By Equals
int result = 0;
for (Iterator iter = collection.iterator(); iter.hasNext();) {
    Object element = iter.next();
    if (element.equals(obj)) {
        result++;
return result;
...
booleancontent_equality(Collection A, Collection B)
this can be an expensive operation, intended for testing not operating code
if (A == B)
    return true;
if (A == null || B == null)
    return false;
if (A.size() != B.size())
    return false;
Set<N> elements = new HashSet<N>();
elements.addAll(A);
...
booleancontentEquals(Collection l1, Collection l2)
content Equals
return l1.containsAll(l2) && l1.size() == l2.size();
booleancontentEquals(Collection list1, Collection list2)
content Equals
if (list1 == list2) {
    return true;
if (list1 == null || list2 == null) {
    return false;
if (list1.size() != list2.size()) {
    return false;
...