Java List Compare compareListsAndNull(List arg1, List arg2)

Here you can find the source of compareListsAndNull(List arg1, List arg2)

Description

compare Lists And Null

License

Open Source License

Declaration

public static boolean compareListsAndNull(List arg1, List arg2) 

Method Source Code


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

import java.util.List;

public class Main {
    public static boolean compareListsAndNull(List arg1, List arg2) {
        if (arg1 == null && arg2 == null) {
            return true;
        } else if ((arg1 == null && arg2 != null) || (arg1 != null && arg2 == null) || arg1.size() != arg2.size()) {
            return false;
        } else {//  ww  w.j  a va  2s  .co m
            for (int i = 0; i < arg1.size(); i++) {
                if (!compareObjectsAndNull(arg1.get(i), arg2.get(i))) {
                    return false;
                }
            }

            return true;
        }
    }

    public static boolean compareObjectsAndNull(Object object1, Object object2) {
        if ((object1 == null && object2 == null) || (object1 != null && object1.equals(object2))) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. compareLists(List a, List b)
  2. compareLists(List a, List b)
  3. compareLists(List list1, List list2)
  4. compareLists(Object obj1, Object obj2)
  5. compareLists(String list1[], String list2[])
  6. comparer(Comparator comparator, T object, T... withList)
  7. compareStringList(List list1, List list2)
  8. compareStringLists(List elements1, List elements2)
  9. compareSubstring(List pieces, String s)