Java List Null Empty equalsEmptyEqNull(List list1, List list2)

Here you can find the source of equalsEmptyEqNull(List list1, List list2)

Description

equals Empty Eq Null

License

Apache License

Declaration

public static <T> boolean equalsEmptyEqNull(List<T> list1, List<T> list2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static <T> boolean equalsEmptyEqNull(List<T> list1, List<T> list2) {
        if ((list1 == null || list1.isEmpty()) && (list2 == null || list2.isEmpty())) {
            return true;
        }/*from  ww  w  .  j a va 2s  . c om*/
        if (list1 == null || list2 == null) {
            return false;
        }
        for (int i = 0; i < list1.size(); i++) {
            if (!list1.get(i).equals(list2.get(i))) {
                return false;
            }
        }
        return true;
    }

    public static <T> boolean equals(List<T> list1, List<T> list2) {
        if (list1 == null && list2 == null) {
            return true;
        }
        if (list1 == null || list2 == null) {
            return false;
        }
        for (int i = 0; i < list1.size(); i++) {
            if (!list1.get(i).equals(list2.get(i))) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. addNotNull(List list, T t)
  2. countIgnoreNull(List list)
  3. emptyStringList()
  4. emptyToNull(List list)
  5. emptyToNull(List list)
  6. equalsNullSafe(List list1, List list2)
  7. fillEmptyEntries(Iterable keys, Map> map)
  8. fillNull(final List list, final int numElements)
  9. fillNull(List lst, int size)