Java Object Equal isEquals(Object object1, Object object2)

Here you can find the source of isEquals(Object object1, Object object2)

Description

is Equals

License

Apache License

Declaration

public static boolean isEquals(Object object1, Object object2) 

Method Source Code

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

import java.util.Arrays;

public class Main {

    public static boolean isEquals(Object object1, Object object2) {
        if (object1 == object2) {
            return true;
        }/*from  w w  w  . j a  va 2 s.c om*/

        if (object1 == null || object2 == null) {
            return false;
        }

        if (!object1.getClass().equals(object2.getClass())) {
            return false;
        }

        if (object1 instanceof Object[]) {
            return Arrays.deepEquals((Object[]) object1, (Object[]) object2);
        } else if (object1 instanceof int[]) {
            return Arrays.equals((int[]) object1, (int[]) object2);
        } else if (object1 instanceof long[]) {
            return Arrays.equals((long[]) object1, (long[]) object2);
        } else if (object1 instanceof short[]) {
            return Arrays.equals((short[]) object1, (short[]) object2);
        } else if (object1 instanceof byte[]) {
            return Arrays.equals((byte[]) object1, (byte[]) object2);
        } else if (object1 instanceof double[]) {
            return Arrays.equals((double[]) object1, (double[]) object2);
        } else if (object1 instanceof float[]) {
            return Arrays.equals((float[]) object1, (float[]) object2);
        } else if (object1 instanceof char[]) {
            return Arrays.equals((char[]) object1, (char[]) object2);
        } else if (object1 instanceof boolean[]) {
            return Arrays.equals((boolean[]) object1, (boolean[]) object2);
        } else {
            return object1.equals(object2);
        }
    }
}

Related

  1. equals(Object v1, Object v2)
  2. equals(Object x, Object y)
  3. equals(Object... objects)
  4. internalEquals(Object[] o1, Object[] o2)
  5. isEquals(final Object lhs, final Object rhs)
  6. nullSafeEquals(Object o1, Object o2)
  7. nullSafeEquals(Object o1, Object o2)
  8. objectsEqual(final Object objectA, final Object objectB)
  9. objectsEqual(Object a, Object b)