com.metamatrix.core.util
Class EquivalenceUtil

java.lang.Object
  extended by com.metamatrix.core.util.EquivalenceUtil

public class EquivalenceUtil
extends java.lang.Object

Utilities to test the equivalence (see method-specific definitions) of any two object/array references.


Constructor Summary
protected EquivalenceUtil()
          Cannot be instantiated
 
Method Summary
static boolean areEqual(java.lang.Object obj1, java.lang.Object obj2)
          Tests whether two object references refer to equal objects.
static boolean areEquivalent(java.lang.Object[] array1, java.lang.Object[] array2)
          Tests whether two arrays are equivalent.
static boolean areStrictlyEquivalent(java.lang.Object[] array1, java.lang.Object[] array2)
          Tests whether the array references are equivalent, but are not the same.
static boolean areStrictlyEquivalent(java.lang.Object obj1, java.lang.Object obj2)
          Tests whether two objects references are equivalent but not the same object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EquivalenceUtil

protected EquivalenceUtil()
Cannot be instantiated

Method Detail

areEqual

public static boolean areEqual(java.lang.Object obj1,
                               java.lang.Object obj2)
Tests whether two object references refer to equal objects. The object references can both be null, in which case they are also considered equal.

Parameters:
obj1 - object reference
obj2 - object reference
Returns:
true if both references are null, OR if neither is null and both objects are equal; false otherwise

areEquivalent

public static boolean areEquivalent(java.lang.Object[] array1,
                                    java.lang.Object[] array2)
Tests whether two arrays are equivalent. This method ignores the array types, but checks the number of references in each array, and the equivalence of those references (in ascending index order).

Parameters:
array1 - an object array
array2 - an object array

areStrictlyEquivalent

public static boolean areStrictlyEquivalent(java.lang.Object obj1,
                                            java.lang.Object obj2)
Tests whether two objects references are equivalent but not the same object. If both references are the same, this method will return false;

Parameters:
obj1 - object reference
obj2 - object reference
Returns:
true if the two references are unequal, and the objects they refer to are equal

areStrictlyEquivalent

public static boolean areStrictlyEquivalent(java.lang.Object[] array1,
                                            java.lang.Object[] array2)
Tests whether the array references are equivalent, but are not the same. This method checks for the strict equivalence of each pair of objects in the two arrays (i.e. corresponding objects cannot be the same but must be equivalent) in ascending index order. This method also considers a null array and a 0-length array equivalent, and ignores the array type.

Parameters:
array1 - an object array
array2 - an object array
Returns:
true if the arrays are equivalent, but not the same.


Copyright © 2009. All Rights Reserved.