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

public static boolean isEquals(final Object o, final Object o2) {
    if (o != o2) {
        if (o != null) {
            if (o.equals(o2)) {
                return true;
            }/*  w  ww . j av  a  2 s . c o m*/
        }
        return false;
    }
    return true;
}

From source file:Main.java

private static boolean compareItems(Object expected, Object actual) {
    if (null == expected && null == actual)
        return true;
    return expected.equals(actual);
}

From source file:Main.java

public static void serializeIfNotEqual(XmlSerializer serializer, String ns, String tag, Object value,
        Object forbiddenValue) throws Exception {
    if (value == null || value.equals(forbiddenValue))
        return;//from  w w  w .  j  av  a 2  s . c  o  m

    serializer.startTag(ns, tag);
    serializer.text(value.toString());
    serializer.endTag(ns, tag);
}

From source file:Main.java

public static int cardinality(java.lang.Object obj, Collection coll) {
    int numObject = 0;
    if (coll != null) {
        Iterator iter = coll.iterator();

        while (iter.hasNext()) {
            Object collObj = iter.next();

            if (collObj != null) {
                if (collObj.equals(obj)) {
                    numObject++;//from www. ja v  a  2s . c  o  m
                }
            }

        }
    }
    return numObject;
}

From source file:Main.java

private static Object arrayRemoveInternal(Object array, Object elementToRemove) {
    boolean found = false;
    final int oldLength = Array.getLength(array);
    if (oldLength == 0) {
        return array;
    }/*  w ww  .  j  a va  2s .c  om*/
    final int newLength = oldLength - 1;
    final Object result = Array.newInstance(array.getClass().getComponentType(), newLength);
    int nextIndex = 0;
    for (int i = 0; i < oldLength; i++) {
        final Object e = Array.get(array, i);
        if (e.equals(elementToRemove)) {
            found = true;
        } else {
            if (nextIndex == newLength) {
                break;
            }
            Array.set(result, nextIndex, e);
            nextIndex++;
        }
    }
    if (!found) {
        return array;
    }
    return result;
}

From source file:Main.java

/**
 * Convenience method for retrieving the UIDefault for a single property of
 * a particular class./*from   w  w w  .j a  v a2 s  .com*/
 *
 * @param clazz the class of interest
 * @param property the property to query
 * @return the UIDefault property, or null if not found
 */
public static Object getUIDefaultOfClass(Class clazz, String property) {
    Object retVal = null;
    UIDefaults defaults = getUIDefaultsOfClass(clazz);
    List<Object> listKeys = Collections.list(defaults.keys());
    for (Object key : listKeys) {
        if (key.equals(property)) {
            return defaults.get(key);
        }
        if (key.toString().equalsIgnoreCase(property)) {
            retVal = defaults.get(key);
        }
    }
    return retVal;
}

From source file:com.erinors.hpb.tests.HpbTestUtils.java

private static boolean equal(Object a, Object b) {
    return a == b || (a != null && a.equals(b));
}

From source file:Main.java

public static boolean equalsList(Collection<?> c1, Collection<?> c2) {
    boolean equals;
    if (c1 == null) {
        equals = (c2 == null);/*from  ww  w .j a  v a 2 s.co m*/
    } else if (c2 == null) {
        equals = false;
    } else if (c1.size() == c2.size()) {
        equals = true;
        Iterator<?> iterC1 = c1.iterator();
        Iterator<?> iterC2 = c2.iterator();
        while (equals && iterC1.hasNext() && iterC2.hasNext()) {
            Object o1 = iterC1.next();
            Object o2 = iterC2.next();
            equals = o1.equals(o2);
        }
    } else {
        equals = false;
    }
    return equals;
}

From source file:com.sylvanaar.idea.Lua.editor.inspections.utils.BoolUtils.java

public static boolean isTrue(LuaConditionalExpression condition) {
    Object value = ObjectUtils.defaultIfNull(condition.evaluate(), UNKNOWN);
    return value.equals(Boolean.TRUE);
}

From source file:com.sylvanaar.idea.Lua.editor.inspections.utils.BoolUtils.java

public static boolean isFalse(LuaConditionalExpression condition) {
    Object value = ObjectUtils.defaultIfNull(condition.evaluate(), UNKNOWN);

    return value.equals(Boolean.FALSE);
}