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

booleanequalTestData(Collection receivedDataSet)
equal Test Data
if (receivedDataSet.size() != TEST_DATA.length) {
    return false;
for (String td : TEST_DATA) {
    if (!receivedDataSet.contains(td)) {
        return false;
return true;
TgetContainedEquals(Collection a, T b)
get Contained Equals
for (T t : a) {
    if (b.equals(t))
        return t;
return null;
intindexOfEquals(Collection collection, T element)
index Of Equals
int pos = 0;
for (T e : collection) {
    if (element.equals(e))
        return pos;
    pos++;
return -1;
booleanisCollectionEqual(Collection c1, Collection c2)
is Collection Equal
if (c1 == null) {
    return c2 == null;
if (c2 == null) {
    return false;
return c1.size() == c2.size() && c1.containsAll(c2);
booleanisCollectionsEqual(Collection f1, Collection f2)
Compare two collections.
if ((f1 == null && f2 != null) || (f1 != null && f2 == null)) {
    return false;
if (f1 != null) {
    if ((f1.size() != f2.size()) || !isC2InC1(f1, f2) || !isC2InC1(f2, f1)) {
        return false;
return true;
booleanisContentEqual(final Collection collectionA, final Collection collectionB)
Method checks if the given collections contain the same content.
if (collectionA == null || collectionB == null) {
    throw new IllegalArgumentException("parameters can not be null.");
if (collectionA.size() != collectionB.size()) {
    return false;
for (Object obj : collectionA) {
    if (!collectionB.contains(obj)) {
...
booleanisEqual(Collection left, Collection right)
is Equal
if (left != null && right != null) {
    return left.toString().equals(right.toString());
} else {
    return left == right;
booleanisEqual(Collection one, Collection two)
Calculates the equality of two collections disregarding the underlying implementation.
if (one == null && two != null) {
    return false;
if (one != null && two == null) {
    return false;
if (one == two) {
    return true;
...
booleanisEqual(Collection coll, Comparator comp)
is Equal
Iterator<? extends T> i = coll.iterator();
T first = i.next();
while (i.hasNext()) {
    T next = i.next();
    if (comp.compare(first, next) < 0) {
        return false;
return true;
booleanisEqual(Collection a, Collection b)
is Equal
if (a == null) {
    return b == null;
if (b == null) {
    return false;
if (a.size() != b.size()) {
    return false;
...