Java List Equal equalsBasedOnEntryIdentity(final List a, final List b)

Here you can find the source of equalsBasedOnEntryIdentity(final List a, final List b)

Description

equals Based On Entry Identity

License

Open Source License

Declaration

public static <T> boolean equalsBasedOnEntryIdentity(final List<T> a, final List<T> b) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Copyright (c) 2015 Oracle and Liferay
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w  w w. j  a  v a2s  .  co  m*/
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
 *    Gregory Amerson - [358295] Need access to selection in list property editor
 ******************************************************************************/

import java.util.List;

public class Main {
    public static <T> boolean equalsBasedOnEntryIdentity(final List<T> a, final List<T> b) {
        if (a == b) {
            return true;
        }

        if (a == null || b == null) {
            return false;
        }

        final int aSize = a.size();
        final int bSize = b.size();

        if (aSize == bSize) {
            for (int i = 0; i < aSize; i++) {
                if (a.get(i) != b.get(i)) {
                    return false;
                }
            }

            return true;
        }

        return false;
    }
}

Related

  1. equals(List list1, List list2)
  2. equals(List lhs, List rhs)
  3. equals(List lhs, List rhs, Comparator comparator)
  4. equals(List list1, List list2)
  5. equalsAny(String toMatch, List matchesAny)
  6. equalShallow(List list0, List list1)
  7. isEqual(Collection listA, Collection listB)
  8. isEqual(List list1, List list2)
  9. isEqual(List from, List to)