Package nl.jqno.equalsverifier.api
Class MultipleTypeEqualsVerifierApi
- java.lang.Object
-
- nl.jqno.equalsverifier.api.MultipleTypeEqualsVerifierApi
-
- All Implemented Interfaces:
EqualsVerifierApi<Void>
public class MultipleTypeEqualsVerifierApi extends Object implements EqualsVerifierApi<Void>
Helps to construct anEqualsVerifier
test for several types at once with a fluent API.
-
-
Field Summary
-
Fields inherited from interface nl.jqno.equalsverifier.api.EqualsVerifierApi
WEBSITE_URL
-
-
Constructor Summary
Constructors Constructor Description MultipleTypeEqualsVerifierApi(List<Class<?>> types, ConfiguredEqualsVerifier ev)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultipleTypeEqualsVerifierApi
except(Class<?> type, Class<?>... more)
Removes the given type or types from the list of types to verify.MultipleTypeEqualsVerifierApi
except(Predicate<Class<?>> exclusionPredicate)
Removes all types matching the given Predicate.List<EqualsVerifierReport>
report()
Performs the verifications of the contracts forequals
andhashCode
and returns a List ofEqualsVerifierReport
with the results of the verifications.MultipleTypeEqualsVerifierApi
suppress(Warning... warnings)
Suppresses warnings given byEqualsVerifier
.MultipleTypeEqualsVerifierApi
usingGetClass()
Signals thatgetClass
is used in the implementation of theequals
method, instead of aninstanceof
check.void
verify()
Performs the verification of the contracts forequals
andhashCode
and throws anAssertionError
if there is a problem.<S> MultipleTypeEqualsVerifierApi
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> MultipleTypeEqualsVerifierApi
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> MultipleTypeEqualsVerifierApi
withPrefabValues(Class<S> otherType, S red, S blue)
Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.
-
-
-
Constructor Detail
-
MultipleTypeEqualsVerifierApi
public MultipleTypeEqualsVerifierApi(List<Class<?>> types, ConfiguredEqualsVerifier ev)
-
-
Method Detail
-
suppress
public MultipleTypeEqualsVerifierApi suppress(Warning... warnings)
Suppresses warnings given byEqualsVerifier
. SeeWarning
to see what warnings can be suppressed.- Specified by:
suppress
in interfaceEqualsVerifierApi<Void>
- Parameters:
warnings
- A list of warnings to suppress inEqualsVerifier
.- Returns:
this
, for easy method chaining.
-
withPrefabValues
public <S> MultipleTypeEqualsVerifierApi withPrefabValues(Class<S> otherType, S red, S blue)
Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.- Specified by:
withPrefabValues
in 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> MultipleTypeEqualsVerifierApi 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:
withGenericPrefabValues
in 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> MultipleTypeEqualsVerifierApi 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:
withGenericPrefabValues
in 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
public MultipleTypeEqualsVerifierApi usingGetClass()
Signals thatgetClass
is used in the implementation of theequals
method, instead of aninstanceof
check.- Specified by:
usingGetClass
in interfaceEqualsVerifierApi<Void>
- Returns:
this
, for easy method chaining.- See Also:
Warning.STRICT_INHERITANCE
-
except
public MultipleTypeEqualsVerifierApi except(Class<?> type, Class<?>... more)
Removes the given type or types from the list of types to verify.- Parameters:
type
- A type to remove from the list of types to verify.more
- More types to remove from the list of types to verify.- Returns:
this
, for easy method chaining.
-
except
public MultipleTypeEqualsVerifierApi except(Predicate<Class<?>> exclusionPredicate)
Removes all types matching the given Predicate.- Parameters:
exclusionPredicate
- A Predicate matching classes to remove from the list of types to verify.- Returns:
this
, for easy method chaining.
-
verify
public void verify()
Performs the verification of the contracts forequals
andhashCode
and throws anAssertionError
if there is a problem.- Throws:
AssertionError
- If one of the contracts is not met, or ifEqualsVerifier
's preconditions do not hold.
-
report
public List<EqualsVerifierReport> report()
Performs the verifications of the contracts forequals
andhashCode
and returns a List ofEqualsVerifierReport
with the results of the verifications.- Returns:
- A List of
EqualsVerifierReport
that indicates whether the contracts are met and whetherEqualsVerifier
's preconditions hold.
-
-