- 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.- Since:
- 3.2
-
Method Summary
Modifier and TypeMethodDescriptionSets modes that influence howEqualsVerifieroperates.Suppresses 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.<S> EqualsVerifierApi<T> withPrefabValues(Class<S> otherType, S red, S blue, S redCopy) Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.<S> EqualsVerifierApi<T> withResettablePrefabValues(Class<S> otherType, Supplier<S> red, Supplier<S> blue) Adds Suppliers for resettable prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.
-
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.- Since:
- 0.6
-
set
Sets modes that influence howEqualsVerifieroperates.- Parameters:
modes- A list of modes to influence howEqualsVerifieroperates.- Returns:
this, for easy method chaining.- Since:
- 4.0
-
withPrefabValues
Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself. This overload will attempt to copyred. If that fails, use the other overload.- 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.- Since:
- 0.2
-
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.redCopy- A copy ofred.- Returns:
this, for easy method chaining.- Throws:
NullPointerException- If eitherotherType,red, orblueis null.IllegalArgumentException- Ifredequalsblue.- Since:
- 4.4
-
withResettablePrefabValues
<S> EqualsVerifierApi<T> withResettablePrefabValues(Class<S> otherType, Supplier<S> red, Supplier<S> blue) Adds Suppliers for resettable prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself. Resettable values are values that are created new every time a new instance ofTis constructed within EqualsVerifier. This can be useful whenTmutates its instances ofS.- 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.- Since:
- 4.1
-
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.- Since:
- 3.0
-
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.- Since:
- 3.0
-
usingGetClass
EqualsVerifierApi<T> usingGetClass()Signals thatgetClassis used in the implementation of theequalsmethod, instead of aninstanceofcheck.- Returns:
this, for easy method chaining.- Since:
- 0.7
- 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.- Since:
- 3.15
-