java.lang.Object
nl.jqno.equalsverifier.api.ConfiguredEqualsVerifier
- All Implemented Interfaces:
EqualsVerifierApi<Void>
Keeps a re-usable configuration for EqualsVerifier.
- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.objenesis.Objenesisprivate final UserPrefabValueCachesprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.privateConfiguredEqualsVerifier(EnumSet<Warning> warningsToSuppress, Set<Mode> modes, UserPrefabValueCaches userPrefabs, boolean usingGetClass, Function<String, String> fieldnameToGetter) Private constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a copy of the configuration.<T> SingleTypeEqualsVerifierApi<T> Factory method.forClasses(Class<?> first, Class<?> second, Class<?>... more) Factory method.forClasses(Iterable<Class<?>> classes) Factory method.<T> SingleTypeEqualsVerifierApi<T> forExamples(T red, T blue) Factory method.forPackage(String packageName, ScanOption... options) Factory method.Sets 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.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.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.withPrefabValues(Class<S> otherType, S red, S blue) Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.withPrefabValues(Class<S> otherType, S red, S blue, S redCopy) Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.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.
-
Field Details
-
warningsToSuppress
-
modesToSet
-
userPrefabs
-
usingGetClass
private boolean usingGetClass -
fieldnameToGetter
-
objenesis
private final org.objenesis.Objenesis objenesis
-
-
Constructor Details
-
ConfiguredEqualsVerifier
public ConfiguredEqualsVerifier()Constructor.- Since:
- 3.0
-
ConfiguredEqualsVerifier
private ConfiguredEqualsVerifier(EnumSet<Warning> warningsToSuppress, Set<Mode> modes, UserPrefabValueCaches userPrefabs, boolean usingGetClass, Function<String, String> fieldnameToGetter) Private constructor. For internal use only.
-
-
Method Details
-
copy
Returns a copy of the configuration.- Returns:
- a copy of the configuration.
- Since:
- 3.2
-
suppress
Suppresses warnings given byEqualsVerifier. SeeWarningto see what warnings can be suppressed.- Specified by:
suppressin interfaceEqualsVerifierApi<Void>- Parameters:
warnings- A list of warnings to suppress inEqualsVerifier.- Returns:
this, for easy method chaining.
-
set
Sets modes that influence howEqualsVerifieroperates.}- Specified by:
setin interfaceEqualsVerifierApi<Void>- Parameters:
modes- A list of modes to influence howEqualsVerifieroperates.- Returns:
this, for easy method chaining.
-
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.- Specified by:
withPrefabValuesin interfaceEqualsVerifierApi<Void>- 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.
-
withPrefabValues
Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.- Specified by:
withPrefabValuesin interfaceEqualsVerifierApi<Void>- 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.
-
withResettablePrefabValues
public <S> ConfiguredEqualsVerifier 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.- Specified by:
withResettablePrefabValuesin interfaceEqualsVerifierApi<Void>- 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.
-
withGenericPrefabValues
public <S> ConfiguredEqualsVerifier 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.- Specified by:
withGenericPrefabValuesin interfaceEqualsVerifierApi<Void>- 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.
-
withGenericPrefabValues
public <S> ConfiguredEqualsVerifier 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.- Specified by:
withGenericPrefabValuesin interfaceEqualsVerifierApi<Void>- 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.
-
usingGetClass
Signals thatgetClassis used in the implementation of theequalsmethod, instead of aninstanceofcheck.- Specified by:
usingGetClassin interfaceEqualsVerifierApi<Void>- Returns:
this, for easy method chaining.- See Also:
-
withFieldnameToGetterConverter
Description copied from interface:EqualsVerifierApiDetermines 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.- Specified by:
withFieldnameToGetterConverterin interfaceEqualsVerifierApi<Void>- Parameters:
converter- A function that converts from field name to getter name.- Returns:
this, for easy method chaining.
-
forClass
Factory method. For general use.- Type Parameters:
T- The type.- Parameters:
type- The class for which theequalsmethod should be tested.- Returns:
- A fluent API for EqualsVerifier.
- Since:
- 3.0
-
forExamples
Factory method. For general use.- Type Parameters:
T- The type.- Parameters:
red- An example of T.blue- An example of T where all fields have different values thanred.- Returns:
- A fluent API for EqualsVerifier.
- Since:
- 4.0
-
forClasses
Factory method. For general use.- Parameters:
classes- An iterable containing the classes for whichequalsmethod should be tested.- Returns:
- A fluent API for EqualsVerifier.
- Since:
- 3.3
-
forClasses
Factory method. For general use.- Parameters:
first- A class for which theequalsmethod should be tested.second- Another class for which theequalsmethod should be tested.more- More classes for which theequalsmethod should be tested.- Returns:
- A fluent API for EqualsVerifier.
- Since:
- 3.2
-
forPackage
Factory method. For general use.Note that this operation may be slow. If the test is too slow, use
forClasses(Class, Class, Class...)instead.- Parameters:
packageName- A package for which each class'sequalsshould be tested.options- Modifications to the standard package scanning behaviour.- Returns:
- A fluent API for EqualsVerifier.
- Since:
- 3.2 / 3.19
-