Java Object Equal objectsEqual(Object o1, Object o2)

Here you can find the source of objectsEqual(Object o1, Object o2)

Description

Returns if two strings are equal.

License

Open Source License

Declaration

public static boolean objectsEqual(Object o1, Object o2) 

Method Source Code

//package com.java2s;
/*/*from   w ww.  ja v  a  2  s .co m*/
 * This file is part of the Scriba source distribution. This is free, open-source 
 * software. For full licensing information, please see the LicensingInformation file
 * at the root level of the distribution.
 *
 * Copyright (c) 2006-2007 Kobrix Software, Inc.
 */

public class Main {
    /**
     * Returns if two strings are equal. This correctly handles null pointers,
     * as opposed to calling <code>o1.equals(o2)</code>.
     * @since jEdit 4.2pre1
     */
    public static boolean objectsEqual(Object o1, Object o2) {
        if (o1 == null) {
            if (o2 == null)
                return true;
            else
                return false;
        } else if (o2 == null)
            return false;
        else
            return o1.equals(o2);
    }
}

Related

  1. nullSafeEquals(Object o1, Object o2)
  2. nullSafeEquals(Object o1, Object o2)
  3. objectsEqual(final Object objectA, final Object objectB)
  4. objectsEqual(Object a, Object b)
  5. objectsEqual(Object lhs, Object rhs)
  6. objectsEqual(Object o1, Object o2)
  7. objectsEqual(Object obj1, Object obj2)
  8. objectsEqual(T a, T b)
  9. safeEquals(Object o1, Object o2)