org.jrdf.util
Class EqualsUtil

java.lang.Object
  extended by org.jrdf.util.EqualsUtil

public final class EqualsUtil
extends Object

A collection of methods that are used for equality testing. The general pattern is: 1/ Test if object (obj, the object passed in) is null, 2/ Test if the object is the same reference, 3/ Test if different class names (prevents subclasses from being equal) OR test if they have a different super class.

Version:
$Revision: 1804 $
Author:
Andrew Newman

Method Summary
static boolean differentClasses(Object thisObject, Object obj)
          Returns true if the two objects have classes with different values (unequal).
static boolean hasSuperClassOrInterface(Class<?> requiredClassOrInterface, Object obj)
          Returns true if the given object can be cast to the superclass or interface.
static boolean isNull(Object obj)
          Return true if the given object is null.
static boolean sameReference(Object thisObject, Object obj)
          Return true if the two objects are of the same reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNull

public static boolean isNull(Object obj)
Return true if the given object is null.

Parameters:
obj - the object to test - who was passed into the equals method.
Returns:
true if the object is null.

sameReference

public static boolean sameReference(Object thisObject,
                                    Object obj)
Return true if the two objects are of the same reference.

Parameters:
thisObject - the object to test - whose equals method we are in.
obj - the object to test - who was passed into the equals method.
Returns:
true if the two objects are of the same reference.

differentClasses

public static boolean differentClasses(Object thisObject,
                                       Object obj)
Returns true if the two objects have classes with different values (unequal).

Parameters:
thisObject - the object to test - whose equals method we are in.
obj - the object to test - who was passed into the equals method.
Returns:
true if the two object are are different classes.

hasSuperClassOrInterface

public static boolean hasSuperClassOrInterface(Class<?> requiredClassOrInterface,
                                               Object obj)
Returns true if the given object can be cast to the superclass or interface.

Parameters:
requiredClassOrInterface - the required superclass or interface.
obj - the object to test - who was passed into the equals method.
Returns:
true if the given object can be cast to the superclass or interface.