Java Utililty Methods Object Equal

List of utility methods to do Object Equal

Description

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

Method

booleanareEqual(final Object x, final Object y)
Like the legacy #equals method, but handles array-specific checks
if (x == y) {
    return true;
if (x == null || y == null) {
    return false;
if (x.equals(y)) {
    return true;
...
booleanareEqual(Object o1, Object o2)
This is a utility method that compares two objects when one or both of the objects might be null The result of this method is determined as follows:
  1. If o1 and o2 are the same object according to the == operator, return true.
    if (o1 == o2) {
        return true;
    } else if (o1 == null || o2 == null) {
        return false;
    } else {
        return o1.equals(o2);
    
booleanareEqual(Object o1, Object o2)
Determines is two objects are equal, accounting for one or both objects being null or the two objects being array types.
boolean objectsAreEqual = false;
if (o1 == o2) {
    objectsAreEqual = true;
} else if (o1 != null && o2 != null) {
    if (o1.getClass().isArray() && o2.getClass().isArray()) {
        objectsAreEqual = Arrays.equals((Object[]) o1, (Object[]) o2);
    } else {
        objectsAreEqual = o1.equals(o2);
...
booleanareEqualStr(Object o1, Object o2)
are Equal Str
if (o1 == o2) {
    return true;
return nvlStr(o1, "").equals(nvlStr(o2, ""));
booleandeepEquals(Object o1, Object o2)
Determines if two objects are equal as determined by Object#equals(Object) , or "deeply equal" if both are arrays.
if (o1 == o2) {
    return true;
if (o1 == null || o2 == null) {
    return false;
Class<?> type1 = o1.getClass();
Class<?> type2 = o2.getClass();
...
booleanequalObjects(Object object1, Object object2)
Indicates whether the given objects are "equal to" each other.
if (object1 == object2) {
    return true;
if (object1 == null) {
    return false;
if (object1.getClass().isArray()) {
    if ((object1 instanceof byte[]) && (object2 instanceof byte[])) {
...
booleanequals(BSONObject a, BSONObject b)
BSON objects are considered equal when their binary encoding matches
return a.keySet().equals(b.keySet()) && Arrays.equals(BSON.encode(a), BSON.encode(b));
booleanequals(final Object a, final Object b)
Check whether two objects are equal
Class<?> c;
if (a == b) {
    return true;
if ((a == null) || (b == null)) {
    return false;
c = a.getClass();
...
booleanequals(Object a, Object b)
equals
if (a instanceof double[] && b instanceof double[]) {
    return Arrays.equals((double[]) a, (double[]) b);
if (a instanceof float[] && b instanceof float[]) {
    return Arrays.equals((float[]) a, (float[]) b);
if (a instanceof long[] && b instanceof long[]) {
    return Arrays.equals((long[]) a, (long[]) b);
...
booleanEquals(Object in1, Object in2)
Equals
if (in1 instanceof int[])
    return Arrays.equals((int[]) in1, (int[]) in2);
else {
    if (((Object[]) in1).length != ((Object[]) in2).length)
        return false;
    for (int i = 0, s = ((Object[]) in1).length; i < s; i++)
        if (!Equals(((Object[]) in1)[i], ((Object[]) in2)[i]))
            return false;
...