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:jp.co.opentone.bsol.linkbinder.util.ValueFormatter.java

/**
 * ??????????./*from  w w  w .  ja v  a  2  s. c  o m*/
 * ??????.
 * @param value 
 * @param code ?
 * @return 
 */
public static String formatLabel(Object value, Object code) {
    if (code == null || !code.equals(value)) {
        return "";
    }
    return MATCH;
}

From source file:Main.java

/**
 * Show input dialog in item selection mode with specified title, message
 * and initial selection.//w  ww  .  j  a  va2 s  .c om
 * 
 * @param parent
 *            the parent component of the input dialog, set {@code null} if
 *            not has one
 * @param title
 *            the title of the dialog
 * @param message
 *            the message to display
 * @param initial
 *            an array of <code>Object</code>s that
 *            gives the possible selections
 * @param selections
 *            the value used to initialize the input
 *            field
 * @return the index of the selected item, or <code>-1</code> if user
 *         canceled input.
 */
public static int selectIndexDialog(Component parent, String title, String message, Object initial,
        Object[] selections) {
    Object obj = JOptionPane.showInputDialog(parent, message, title, JOptionPane.INFORMATION_MESSAGE, null,
            selections, initial);
    if (obj != null)
        for (int i = 0; i < selections.length; i++)
            if (obj.equals(selections[i]))
                return i;
    return -1;
}

From source file:Main.java

/**
 * <p>/*  w  w w  . j  a  v  a 2  s .c  om*/
 * Compare two objects for equality, checking for <code>null</code> values as well.
 * </p>
 */
public static boolean eq(Object left, Object right) {
    if (left == right)
        return true;
    else if (left == null)
        return false;
    else if (right == null)
        return false;
    else
        return left.equals(right);
}

From source file:edu.umn.msi.tropix.common.test.BeanTest.java

public static void testBeanProperties(final Object testBean, final HashMultimap<Class<?>, Object> typeObjects) {
    try {// w w w.ja  v  a  2 s . com
        @SuppressWarnings("unchecked")
        final Map<String, ?> propertyMap = PropertyUtils.describe(testBean);
        for (final String propertyName : propertyMap.keySet()) {
            if (propertyName.equals("class") || !PropertyUtils.isWriteable(testBean, propertyName)) {
                continue;
            }
            final Class<?> type = PropertyUtils.getPropertyType(testBean, propertyName);
            Collection<?> objects = null;
            for (final Class<?> typeQuery : typeObjects.keySet()) {
                if (typeQuery.isAssignableFrom(type)) {
                    objects = typeObjects.get(typeQuery);
                }
            }
            boolean useEquals = true;
            if (objects == null) {
                useEquals = false;
                try {
                    objects = Lists.<Object>newArrayList(EasyMock.createMock(type));
                } catch (final Exception e) {
                    // Cannot instantiate mock of this type
                    continue;
                }
            }
            for (final Object expectedObject : objects) {
                PropertyUtils.setProperty(testBean, propertyName, expectedObject);
                final Object object = PropertyUtils.getProperty(testBean, propertyName);
                if (useEquals) {
                    assert object.equals(expectedObject) : "Expected " + expectedObject + " obtained " + object;
                } else {
                    assert object == expectedObject : "Expected " + expectedObject + " obtained " + object;
                }
            }
        }
    } catch (final Exception e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.aw.support.beans.PropertyComparator.java

public static boolean safeEquals(Object obj1, Object obj2) {
    if (obj1 == null && obj2 == null)
        return true;
    if (obj1 != null)
        return obj1.equals(obj2);
    else/*from  ww  w . j  av a2 s .co m*/
        return obj2.equals(obj1);
}

From source file:com.wavemaker.commons.util.WMUtils.java

public static boolean areObjectsEqual(Object o1, Object o2) {
    if (o1 == o2) {
        return true;
    }//from w w  w . ja  va  2 s  .  c om
    if (o1 == null || o2 == null) {
        return false;
    }
    return o1.equals(o2);
}

From source file:com.linkedin.databus2.schemas.utils.Utils.java

public static boolean equals(Object x, Object y) {
    if (x == y)//from   w w w . j  a  v  a 2s .  co m
        return true;
    else if (x == null)
        return false;
    else if (y == null)
        return false;
    else
        return x.equals(y);
}

From source file:au.com.dw.testing.AssertUtil.java

/**
 * Check for equality.// w w  w  . j a  v a2 s  .  co m
 * 
 * @param expected
 * @param actual
 * @return
 */
private static boolean isEquals(Object expected, Object actual) {
    return expected.equals(actual);
}

From source file:com.anathema_roguelike.main.utilities.Utils.java

public static String getDescription(Object obj) {

    if (obj instanceof String || obj.equals(String.class)) {
        return "";
    }/*from w ww  .  j  a  va2 s.c  o m*/

    return getProperty(descriptions, obj, getName(obj) + " MISSING DESCRIPTION");
}

From source file:Main.java

public static boolean mapMatchesFields(Map<String, Object> baseMap, Map<String, Object> compareMap) {
    for (Map.Entry<String, Object> entry : compareMap.entrySet()) {
        Object compareObj = compareMap.get(entry.getKey());
        Object baseObj = baseMap.get(entry.getKey());
        if (compareObj == null) {
            if (baseObj != null)
                return false;
        } else {/* w  w  w. ja v a  2  s  .  c om*/
            if (!compareObj.equals(baseObj))
                return false;
        }
    }
    return true;
}