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:Main.java

/**
 * Dictionary does not have an equals./*from  w ww .  j  a  v  a2 s. co m*/
 * Please use  Map.equals()
 *
 * <p>Follows the equals contract of Java 2's Map.</p>
 *
 * @since Ant 1.5
 * @deprecated
 */
public static boolean equals(Dictionary d1, Dictionary d2) {
    if (d1 == d2) {
        return true;
    }

    if (d1 == null || d2 == null) {
        return false;
    }

    if (d1.size() != d2.size()) {
        return false;
    }

    Enumeration e1 = d1.keys();
    while (e1.hasMoreElements()) {
        Object key = e1.nextElement();
        Object value1 = d1.get(key);
        Object value2 = d2.get(key);
        if (value2 == null || !value1.equals(value2)) {
            return false;
        }
    }

    // don't need the opposite check as the Dictionaries have the
    // same size, so we've also covered all keys of d2 already.

    return true;
}

From source file:com.l2jfree.lang.L2System.java

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

From source file:com.facebook.model.JsonUtil.java

static boolean jsonObjectContainsValue(JSONObject jsonObject, Object value) {
    @SuppressWarnings("unchecked")
    Iterator<String> keys = jsonObject.keys();
    while (keys.hasNext()) {
        Object thisValue = jsonObject.opt(keys.next());
        if (thisValue != null && thisValue.equals(value)) {
            return true;
        }//w  w w .  j a  v a 2s. c  o  m
    }
    return false;
}

From source file:harschware.collections.containers.Triplet.java

private static final boolean equal(Object o1, Object o2) {
    if (o1 == null) {
        return o2 == null;
    }/*w  w w. j a v a  2  s .  c  o m*/
    return o1.equals(o2);
}

From source file:Main.java

public static boolean equal(Object o1, Object o2) {
    if (o1 == o2) {
        return true;
    } else if (o1 == null || o2 == null) {
        return false;
    } else {//w w w.ja v a2 s  .  co  m
        return o1.equals(o2);
    }
}

From source file:de.mpc.pia.tools.PIATools.java

/**
 * Checks whether both objects are null or are equal.
 *///from w  ww. j  a  va  2s.  c  om
public static boolean bothNullOrEqual(Object x, Object y) {
    return x == null ? y == null : x.equals(y);
}

From source file:egovframework.rte.fdl.string.EgovObjectUtil.java

/**
 * ? Null ? ?./*from ww w . j  a v  a 2 s  . c o  m*/
 * @param object
 * @return Null? true / Null?  false
 */
public static boolean isNull(Object object) {
    return ((object == null) || object.equals(null));
}

From source file:de.cosmocode.junit.Asserts.java

/**
 * Asserts two objects are not equals./*from  ww w  .j  av  a  2 s .  co m*/
 * 
 * Succeed if expected is null.
 * Fails if expected is equals to actual.
 * 
 * @param expected the value to check the other parameter against
 * @param actual the value to check
 */
public static void assertNotEquals(Object expected, Object actual) {
    if (expected == null)
        return;
    if (expected.equals(actual)) {
        fail("expected not equals:<" + expected + "> was :<" + actual + ">");
    }
}

From source file:Main.java

/**
 * Returns <code>true</code> if any two items in the array are equal to
 * one another.  Any <code>null</code> values in the array are ignored.
 *
 * @param array  the array to check./*from w  w  w .  j a va2s .  co m*/
 *
 * @return A boolean.
 */
public static boolean hasDuplicateItems(final Object[] array) {
    for (int i = 0; i < array.length; i++) {
        for (int j = 0; j < i; j++) {
            final Object o1 = array[i];
            final Object o2 = array[j];
            if (o1 != null && o2 != null) {
                if (o1.equals(o2)) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:it.govpay.model.BasicModel.java

public static boolean equals(Object a, Object b) {
    if (a == null)
        return b == null;

    return a.equals(b);
}