Package org.elasticsearch.test
Class EqualsHashCodeTestUtils
java.lang.Object
org.elasticsearch.test.EqualsHashCodeTestUtils
Utility class that encapsulates standard checks and assertions around testing the equals() and hashCode()
methods of objects that implement them.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A function that makes a copy of its input argumentstatic interface
A function that creates a copy of its input argument that is different from its input in exactly one aspect (e.g. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
checkEqualsAndHashCode
(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction) Perform common equality and hashCode checks on the input objectstatic <T> void
checkEqualsAndHashCode
(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction, EqualsHashCodeTestUtils.MutateFunction<T> mutationFunction) Perform common equality and hashCode checks on the input object
-
Constructor Details
-
EqualsHashCodeTestUtils
public EqualsHashCodeTestUtils()
-
-
Method Details
-
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
-