Package nl.jqno.equalsverifier.api
Interface EqualsVerifierApi<T>
- Type Parameters:
T
- The class under test.
- All Known Implementing Classes:
ConfiguredEqualsVerifier
,MultipleTypeEqualsVerifierApi
,SingleTypeEqualsVerifierApi
public interface EqualsVerifierApi<T>
Helps to construct an
EqualsVerifier
test with a fluent API.-
Method Summary
Modifier and TypeMethodDescriptionSuppresses warnings given byEqualsVerifier
.Signals thatgetClass
is used in the implementation of theequals
method, instead of aninstanceof
check.<S> EqualsVerifierApi<T>
withGenericPrefabValues
(Class<S> otherType, Func.Func1<?, S> factory) Adds a factory to generate prefabricated values for instance fields of classes with 1 generic type parameter that EqualsVerifier cannot instantiate by itself.<S> EqualsVerifierApi<T>
withGenericPrefabValues
(Class<S> otherType, Func.Func2<?, ?, S> factory) Adds a factory to generate prefabricated values for instance fields of classes with 2 generic type parameters that EqualsVerifier cannot instantiate by itself.<S> EqualsVerifierApi<T>
withPrefabValues
(Class<S> otherType, S red, S blue) Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.Signals that all internal caches need to be reset.
-
Method Details
-
suppress
Suppresses warnings given byEqualsVerifier
. SeeWarning
to see what warnings can be suppressed.- Parameters:
warnings
- A list of warnings to suppress inEqualsVerifier
.- Returns:
this
, for easy method chaining.
-
withPrefabValues
Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.- Type Parameters:
S
- The class of the prefabricated values.- Parameters:
otherType
- The class of the prefabricated values.red
- An instance ofS
.blue
- Another instance ofS
, not equal tored
.- Returns:
this
, for easy method chaining.- Throws:
NullPointerException
- If eitherotherType
,red
, orblue
is null.IllegalArgumentException
- Ifred
equalsblue
.
-
withGenericPrefabValues
Adds a factory to generate prefabricated values for instance fields of classes with 1 generic type parameter that EqualsVerifier cannot instantiate by itself.- Type Parameters:
S
- The class of the prefabricated values.- Parameters:
otherType
- The class of the prefabricated values.factory
- A factory to generate an instance ofS
, given a value of its generic type parameter.- Returns:
this
, for easy method chaining.- Throws:
NullPointerException
- if eitherotherType
orfactory
is null.
-
withGenericPrefabValues
Adds a factory to generate prefabricated values for instance fields of classes with 2 generic type parameters that EqualsVerifier cannot instantiate by itself.- Type Parameters:
S
- The class of the prefabricated values.- Parameters:
otherType
- The class of the prefabricated values.factory
- A factory to generate an instance ofS
, given a value of each of its generic type parameters.- Returns:
this
, for easy method chaining.- Throws:
NullPointerException
- if eitherotherType
orfactory
is null.
-
usingGetClass
EqualsVerifierApi<T> usingGetClass()Signals thatgetClass
is used in the implementation of theequals
method, instead of aninstanceof
check.- Returns:
this
, for easy method chaining.- See Also:
-
withResetCaches
EqualsVerifierApi<T> withResetCaches()Signals that all internal caches need to be reset. This is useful when the test framework uses multiple ClassLoaders to run tests, causingClass
instances that would normally be equal, to be unequal, because their ClassLoaders don't match.- Returns:
this
, for easy method chaining.
-