public static final class RecursiveComparisonConfiguration.Builder extends Object
RecursiveComparisonConfiguration.| Modifier and Type | Method and Description |
|---|---|
RecursiveComparisonConfiguration |
build() |
RecursiveComparisonConfiguration.Builder |
withComparatorForFields(Comparator<?> comparator,
String... fields)
Registers the given
Comparator to compare the fields at the given locations. |
<T> RecursiveComparisonConfiguration.Builder |
withComparatorForType(Comparator<? super T> comparator,
Class<T> type)
Registers the given
Comparator to compare the fields with the given type. |
RecursiveComparisonConfiguration.Builder |
withComparedFields(String... fieldsToCompare)
Adds the given fields to the set of fields from the object under test to compare in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withEqualsForFields(BiPredicate<?,?> equals,
String... fields)
Registers the given
BiPredicate to compare the fields at the given locations. |
<T> RecursiveComparisonConfiguration.Builder |
withEqualsForType(BiPredicate<? super T,? super T> equals,
Class<T> type)
Registers the given
BiPredicate to compare the fields with the given type. |
RecursiveComparisonConfiguration.Builder |
withErrorMessageForFields(String message,
String... fields)
Registers the giving message which would be shown when differences in the given fields while comparison occurred.
|
RecursiveComparisonConfiguration.Builder |
withErrorMessageForType(String message,
Class<?> type)
Registers the giving message which would be shown when differences for the giving type while comparison
occurred.
|
RecursiveComparisonConfiguration.Builder |
withIgnoreAllActualEmptyOptionalFields(boolean ignoreAllActualEmptyOptionalFields)
Sets whether actual empty optional fields are ignored in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoreAllActualNullFields(boolean ignoreAllActualNullFields)
Sets whether actual null fields are ignored in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoreAllExpectedNullFields(boolean ignoreAllExpectedNullFields)
Sets whether expected null fields are ignored in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoreAllOverriddenEquals(boolean ignoreAllOverriddenEquals)
Force a recursive comparison on all fields (except java types) if true.
|
RecursiveComparisonConfiguration.Builder |
withIgnoreCollectionOrder(boolean ignoreCollectionOrder)
Sets whether to ignore collection order in the comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredCollectionOrderInFields(String... fieldsToIgnoreCollectionOrder)
Adds the given fields to the list fields from the object under test to ignore collection order in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredCollectionOrderInFieldsMatchingRegexes(String... regexes)
Adds the given regexes to the list of regexes used to find the object under test fields to ignore collection order in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredFields(String... fieldsToIgnore)
Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredFieldsMatchingRegexes(String... regexes)
Allows to ignore in the recursive comparison the object under test fields matching the given regexes.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredFieldsOfTypes(Class<?>... types)
Adds the given types to the list fields from the object under test types to ignore in the recursive comparison.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredOverriddenEqualsForFields(String... fields)
Adds the given fields to the list of fields to force a recursive comparison on.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredOverriddenEqualsForFieldsMatchingRegexes(String... regexes)
Adds the given regexes to the list of regexes used find the fields to force a recursive comparison on.
|
RecursiveComparisonConfiguration.Builder |
withIgnoredOverriddenEqualsForTypes(Class<?>... types)
Adds the given types to the list of types to force a recursive comparison on.
|
RecursiveComparisonConfiguration.Builder |
withStrictTypeChecking(boolean strictTypeChecking)
Sets whether the recursive comparison will check that actual's type is compatible with expected's type (the same applies for each field).
|
public RecursiveComparisonConfiguration.Builder withStrictTypeChecking(boolean strictTypeChecking)
See RecursiveComparisonAssert.withStrictTypeChecking() for code examples.
strictTypeChecking - whether the recursive comparison will check that actual's type is compatible with expected's type.public RecursiveComparisonConfiguration.Builder withIgnoreAllActualNullFields(boolean ignoreAllActualNullFields)
See RecursiveComparisonAssert.ignoringActualNullFields() for code examples.
ignoreAllActualNullFields - whether to ignore actual null fields in the recursive comparisonpublic RecursiveComparisonConfiguration.Builder withIgnoreAllActualEmptyOptionalFields(boolean ignoreAllActualEmptyOptionalFields)
See RecursiveComparisonAssert.ignoringActualEmptyOptionalFields() for code examples.
ignoreAllActualEmptyOptionalFields - whether to ignore actual empty optional fields in the recursive comparisonpublic RecursiveComparisonConfiguration.Builder withIgnoreAllExpectedNullFields(boolean ignoreAllExpectedNullFields)
See RecursiveComparisonAssert.ignoringExpectedNullFields() for code examples.
ignoreAllExpectedNullFields - whether to ignore expected null fields in the recursive comparisonpublic RecursiveComparisonConfiguration.Builder withIgnoredFields(String... fieldsToIgnore)
See RecursiveComparisonAssert#ignoringFields(String...) for examples.
fieldsToIgnore - the fields of the object under test to ignore in the comparison.public RecursiveComparisonConfiguration.Builder withComparedFields(String... fieldsToCompare)
Nested fields can be specified like this: home.address.street.
See RecursiveComparisonAssert.comparingOnlyFields(String...) for examples.
fieldsToCompare - the fields of the object under test to compare.public RecursiveComparisonConfiguration.Builder withIgnoredFieldsMatchingRegexes(String... regexes)
See RecursiveComparisonAssert#ignoringFieldsMatchingRegexes(String...) for examples.
regexes - regexes used to ignore fields in the comparison.public RecursiveComparisonConfiguration.Builder withIgnoredFieldsOfTypes(Class<?>... types)
Note that if some object under test fields are null, they are not ignored by this method as their type can't be evaluated.
See RecursiveComparisonAssert#ignoringFieldsOfTypes(Class...) for examples.
types - the types of the object under test to ignore in the comparison.public RecursiveComparisonConfiguration.Builder withIgnoredOverriddenEqualsForTypes(Class<?>... types)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForTypes(Class...) for examples.
types - the types to the list of types to force a recursive comparison on.public RecursiveComparisonConfiguration.Builder withIgnoredOverriddenEqualsForFields(String... fields)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForFields(String...) for examples.
fields - the fields to force a recursive comparison on.public RecursiveComparisonConfiguration.Builder withIgnoredOverriddenEqualsForFieldsMatchingRegexes(String... regexes)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForFieldsMatchingRegexes(String...) for examples.
regexes - regexes used to specify the fields we want to force a recursive comparison on.public RecursiveComparisonConfiguration.Builder withIgnoreAllOverriddenEquals(boolean ignoreAllOverriddenEquals)
See RecursiveComparisonAssert.ignoringAllOverriddenEquals() for examples.
ignoreAllOverriddenEquals - whether to force a recursive comparison on all fields (except java types) or not.public RecursiveComparisonConfiguration.Builder withIgnoreCollectionOrder(boolean ignoreCollectionOrder)
See RecursiveComparisonAssert.ignoringCollectionOrder() for code examples.
ignoreCollectionOrder - whether to ignore collection order in the comparison.public RecursiveComparisonConfiguration.Builder withIgnoredCollectionOrderInFields(String... fieldsToIgnoreCollectionOrder)
See RecursiveComparisonAssert#ignoringCollectionOrderInFields(String...) for examples.
fieldsToIgnoreCollectionOrder - the fields of the object under test to ignore collection order in the comparison.public RecursiveComparisonConfiguration.Builder withIgnoredCollectionOrderInFieldsMatchingRegexes(String... regexes)
See RecursiveComparisonAssert#ignoringCollectionOrderInFieldsMatchingRegexes(String...) for examples.
regexes - regexes used to find the object under test fields to ignore collection order in in the comparison.public <T> RecursiveComparisonConfiguration.Builder withComparatorForType(Comparator<? super T> comparator, Class<T> type)
Comparator to compare the fields with the given type.
Comparators registered with this method have less precedence than comparators registered with withComparatorForFields(Comparator, String...)
or BiPredicate registered with withEqualsForFields(BiPredicate, String...).
Note that registering a Comparator for a given type will override the previously registered BiPredicate/Comparator (if any).
See RecursiveComparisonAssert.withComparatorForType(Comparator, Class) for examples.
T - the class type to register a comparator forcomparator - the Comparator to use to compare the given fieldtype - the type to be compared with the given comparator.NullPointerException - if the given Comparator is null.public <T> RecursiveComparisonConfiguration.Builder withEqualsForType(BiPredicate<? super T,? super T> equals, Class<T> type)
BiPredicate to compare the fields with the given type.
BiPredicates registered with this method have less precedence than the ones registered with withEqualsForFields(BiPredicate, String...)
or the comparators registered with withComparatorForFields(Comparator, String...).
Note that registering a BiPredicate for a given type will override the previously registered BiPredicate/Comparator (if any).
See RecursiveComparisonAssert.withEqualsForType(BiPredicate, Class) for examples.
T - the class type to register a BiPredicate forequals - the BiPredicate to use to compare the given fieldtype - the type to be compared with the given comparator.NullPointerException - if the given BiPredicate is null.public RecursiveComparisonConfiguration.Builder withComparatorForFields(Comparator<?> comparator, String... fields)
Comparator to compare the fields at the given locations.
The fields must be specified from the root object, for example if Foo has a Bar field and both have an id field,
one can register a comparator for Foo and Bar's id by calling:
registerComparatorForFields(idComparator, "foo.id", "foo.bar.id")
Comparators registered with this method have precedence over comparators registered with withComparatorForType(Comparator, Class)
or BiPredicate registered with withEqualsForType(BiPredicate, Class).
Note that registering a Comparator for a given field will override the previously registered BiPredicate/Comparator (if any).
See RecursiveComparisonAssert#withComparatorForFields(Comparator comparator, String...fields) for examples.
comparator - the Comparator to use to compare the given fieldfields - the fields the comparator should be used forNullPointerException - if the given Comparator is null.public RecursiveComparisonConfiguration.Builder withEqualsForFields(BiPredicate<?,?> equals, String... fields)
BiPredicate to compare the fields at the given locations.
The fields must be specified from the root object, for example if Foo has a Bar field and both have an id field,
one can register a BiPredicate for Foo and Bar's id by calling:
withEqualsForFields(idBiPredicate, "foo.id", "foo.bar.id")
BiPredicates registered with this method have precedence over the ones registered with withEqualsForType(BiPredicate, Class)
or the comparators registered with withComparatorForType(Comparator, Class).
Note that registering a BiPredicate for a given field will override the previously registered BiPredicate/Comparator (if any).
See RecursiveComparisonAssert#withEqualsForFields(BiPredicate equals, String...fields) for examples.
equals - the BiPredicate to use to compare the given fieldsfields - the fields the BiPredicate should be used forNullPointerException - if the given BiPredicate is null.public RecursiveComparisonConfiguration.Builder withErrorMessageForFields(String message, String... fields)
The fields must be specified from the root object, for example if Foo has a Bar field and both
have an id field, one can register a message for Foo and Bar's id by calling:
withErrorMessageForFields("some message", "foo.id", "foo.bar.id")
Messages registered with this method have precedence over the ones registered with withErrorMessageForType(String, Class).
In case of null as message the default error message will be used (See
ComparisonDifference.DEFAULT_TEMPLATE).
message - the error message that will be thrown when comparison error occurred.fields - the fields the error message should be used for.NullPointerException - if the giving list of arguments is null.public RecursiveComparisonConfiguration.Builder withErrorMessageForType(String message, Class<?> type)
Message registered with this method have less precedence than the ones registered with withErrorMessageForFields(String, String...).
In case of null as message the default error message will be used (See
ComparisonDifference.DEFAULT_TEMPLATE).
message - the error message that will be thrown when comparison error occurredtype - the type the error message should be used forpublic RecursiveComparisonConfiguration build()
Copyright © 2025. All rights reserved.