Example usage for java.lang Object equals

List of usage examples for java.lang Object equals

Introduction

In this page you can find the example usage for java.lang Object equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.thoughtworks.go.util.ObjectUtil.java

public static boolean nullSafeEquals(Object o1, Object o2) {
    return o1 == null ? o2 == null : o1.equals(o2);
}

From source file:Main.java

public static boolean equalsWithNulls(Object a, Object b) {
    if (a == b)/*from  w  w w .j  a  va2 s.c om*/
        return true;
    if ((a == null) || (b == null))
        return false;
    return a.equals(b);
}

From source file:Main.java

public static final boolean equalsWithNulls(Object a, Object b) {
    if (a == b)/*from   w w w .j av a  2 s.  co m*/
        return true;
    if ((a == null) || (b == null))
        return false;
    return a.equals(b);
}

From source file:Main.java

public static int arraySearch(Object[] array, Object item) {
    if (array == null || item == null)
        return -1;
    for (int i = 0; i < array.length; i++) {
        if (item.equals(array[i]))
            return i;
    }/*  w  ww  .ja va2s.  c  o m*/
    return -1;
}

From source file:Main.java

private static boolean isCommonInput(Object key) {
    if (key == null)
        return false;
    for (int i = 0; i < FIXED_FIELD.length; i++) {
        if (key.equals(FIXED_FIELD[i])) {
            return true;
        }//from   w  ww . j a  va  2  s.c  om
    }

    return false;

}

From source file:com.eryansky.common.utils.ObjectUtils.java

/**
 * ?//  www .ja  v  a  2  s.  c om
 * 
 * @param actual
 * @param expected
 * @return
 *         <ul>
 *         <li>nulltrue</li>
 *         <li>?nulltrue</li>
 *         <li>?false</li>
 *         </ul>
 */
public static boolean isEquals(Object actual, Object expected) {
    return actual == null ? expected == null : actual.equals(expected);
}

From source file:Main.java

/**
 * Returns {@code true} if the two objects are equal.
 *//*from ww w .  j  ava  2 s .c  o m*/
private static boolean equals(Object a, Object b) {
    if (a == null) {
        return b == null;
    }

    return a.equals(b);
}

From source file:Main.java

public static boolean objectEquals(final Object object1, final Object object2) {
    if (object1 == null || object2 == null)
        return object1 == object2;
    return object1.equals(object2);
}

From source file:com.AandC.GemsCraft.Configuration.ConfigKey.java

static boolean isNull(Object o) {
    if (o.equals(null)) {
        return true;
    } else {/*from w w w . j a  v  a2s .co  m*/
        return false;
    }
}

From source file:Main.java

public static int indexOf(Object[] array, Object item) {
    if (item == null || array == null) {
        return -1;
    }//from  ww w .j a  v a 2 s. c  o  m

    for (int i = 0; i < array.length; i++) {
        Object o = array[i];
        if (o == item) {
            return i;
        }

        if (o != null) {
            if (o.equals(item)) {
                return i;
            }
        }
    }
    return -1;
}