Package org.teiid.core.util
Class EquivalenceUtil
- java.lang.Object
-
- org.teiid.core.util.EquivalenceUtil
-
public class EquivalenceUtil extends Object
Utilities to test the equivalence (see method-specific definitions) of any two object/array references.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EquivalenceUtil()
Cannot be instantiated
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areEqual(Object obj1, Object obj2)
Tests whether two object references refer to equal objects.static boolean
areEquivalent(Object[] array1, Object[] array2)
Tests whether two arrays are equivalent.static boolean
areStrictlyEquivalent(Object[] array1, Object[] array2)
Tests whether the array references are equivalent, but are not the same.static boolean
areStrictlyEquivalent(Object obj1, Object obj2)
Tests whether two objects references are equivalent but not the same object.
-
-
-
Method Detail
-
areEqual
public static boolean areEqual(Object obj1, 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 referenceobj2
- 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(Object[] array1, 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 arrayarray2
- an object array
-
areStrictlyEquivalent
public static boolean areStrictlyEquivalent(Object obj1, 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 referenceobj2
- object reference- Returns:
- true if the two references are unequal, and the objects they refer to are equal
-
areStrictlyEquivalent
public static boolean areStrictlyEquivalent(Object[] array1, 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 arrayarray2
- an object array- Returns:
- true if the arrays are equivalent, but not the same.
-
-