Package org.elasticsearch.test
Class EqualsHashCodeTestUtils
- java.lang.Object
-
- org.elasticsearch.test.EqualsHashCodeTestUtils
-
public class EqualsHashCodeTestUtils extends java.lang.ObjectUtility class that encapsulates standard checks and assertions around testing the equals() and hashCode() methods of objects that implement them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEqualsHashCodeTestUtils.CopyFunction<T>A function that makes a copy of its input argumentstatic interfaceEqualsHashCodeTestUtils.MutateFunction<T>A function that creates a copy of its input argument that is different from its input in exactly one aspect (e.g.
-
Constructor Summary
Constructors Constructor Description EqualsHashCodeTestUtils()
-
Method Summary
Modifier and Type Method Description static <T> voidcheckEqualsAndHashCode(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction)Perform common equality and hashCode checks on the input objectstatic <T> voidcheckEqualsAndHashCode(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction, EqualsHashCodeTestUtils.MutateFunction<T> mutationFunction)Perform common equality and hashCode checks on the input object
-
-
-
Method Detail
-
checkEqualsAndHashCode
public static <T> void checkEqualsAndHashCode(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction)Perform common equality and hashCode checks on the input object- Parameters:
original- the object under testcopyFunction- a function that creates a deep copy of the input object
-
checkEqualsAndHashCode
public static <T> void checkEqualsAndHashCode(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction, EqualsHashCodeTestUtils.MutateFunction<T> mutationFunction)Perform common equality and hashCode checks on the input object- Parameters:
original- the object under testcopyFunction- a function that creates a deep copy of the input objectmutationFunction- a function that creates a copy of the input object that is different from the input in one aspect. The output of this call is used to check that it is not equal() to the input object
-
-