Java List Compare compareLists(Object obj1, Object obj2)

Here you can find the source of compareLists(Object obj1, Object obj2)

Description

compare Lists

License

Open Source License

Declaration

public static boolean compareLists(Object obj1, Object obj2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashSet;
import java.util.Iterator;

import java.util.List;

import java.util.Set;

public class Main {
    public static boolean compareLists(Object obj1, Object obj2) {
        if (null == obj1 && null == obj2) {
            return true;
        } else if (null != obj1 && null != obj2) {
            if (obj1 instanceof List && obj2 instanceof List) {
                if (((List) obj1).size() != ((List) obj2).size()) {
                    return false;
                } else {
                    Set set = new HashSet();
                    Iterator i$ = ((List) obj1).iterator();

                    Object objTmp;
                    while (i$.hasNext()) {
                        objTmp = i$.next();
                        if (null != objTmp) {
                            set.add(objTmp);
                        }//from   w w w  . j a  v a 2  s .c  o m
                    }

                    i$ = ((List) obj2).iterator();

                    do {
                        if (!i$.hasNext()) {
                            return true;
                        }

                        objTmp = i$.next();
                    } while (null == objTmp || set.contains(objTmp));

                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
}

Related

  1. compareLists(List l1, List l2)
  2. compareLists(List list, List> listOfLists)
  3. compareLists(List a, List b)
  4. compareLists(List a, List b)
  5. compareLists(List list1, List list2)
  6. compareLists(String list1[], String list2[])
  7. compareListsAndNull(List arg1, List arg2)
  8. comparer(Comparator comparator, T object, T... withList)
  9. compareStringList(List list1, List list2)