Java Utililty Methods List Equal

List of utility methods to do List Equal

Description

The list of methods to do List Equal are organized into topic(s).

Method

booleanisEqual(List from, List to)
is Equal
return (getCommonElements(from, to).size() == from.size()) && (from.size() == to.size());
booleanisEqualAsMultiset(List left, List right)
Checks whether two given lists that are interpreted as multi-sets contain the same elements.
for (Object e : left) {
    if (right.contains(e)) {
        right.remove(e);
    } else {
        return false;
return right.isEmpty();
...
booleanisEqualIgnoringOrder(List left, List right)
is Equal Ignoring Order
if (left != null && right != null) {
    ArrayList sortedLeft = new ArrayList(left);
    ArrayList sortedRight = new ArrayList(right);
    Collections.sort(sortedLeft);
    Collections.sort(sortedRight);
    return sortedLeft.toString().equals(sortedRight.toString());
} else {
    return left == right;
...
booleanisEqualList(List list1, List list2)
check equal without caring about the order.
if (list1 == list2) {
    return true;
if (list1 == null || list2 == null || list1.size() != list2.size()) {
    return false;
for (T obj1 : list1) {
    if (!list2.contains(obj1)) {
...
booleanisEquals(List l1, List l2)
is Equals
if (l1 == l2)
    return true;
if (l1 == null)
    return l2 == null;
if (l2 == null)
    return false;
if (l1.size() != l2.size())
    return false;
...
booleanisEquals(List l1, List l2)
is Equals
if (l1 == null && l2 == null) {
    return true;
if (l1 == null || l2 == null) {
    return false;
if (l1.size() != l2.size()) {
    return false;
...