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 thatgetClassis used in the implementation of theequalsmethod, instead of aninstanceofcheck.withFieldnameToGetterConverter(Function<String, String> converter) Determines how a getter name can be derived from a field name.<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. SeeWarningto 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, orblueis null.IllegalArgumentException- Ifredequalsblue.
-
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 eitherotherTypeorfactoryis 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 eitherotherTypeorfactoryis null.
-
usingGetClass
EqualsVerifierApi<T> usingGetClass()Signals thatgetClassis used in the implementation of theequalsmethod, instead of aninstanceofcheck.- Returns:
this, for easy method chaining.- See Also:
-
withFieldnameToGetterConverter
Determines how a getter name can be derived from a field name. The default behavior is to uppercase the field's first letter and prepend 'get'. For instance, a field name 'employee' would correspond to getter name 'getEmployee'. This method can be used if your project has a different naming convention.- Parameters:
converter- A function that converts from field name to getter name.- Returns:
this, for easy method chaining.
-
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, causingClassinstances that would normally be equal, to be unequal, because their ClassLoaders don't match.- Returns:
this, for easy method chaining.
-