public class RecursiveComparisonConfiguration extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
INDENT_LEVEL_2 |
| Constructor and Description |
|---|
RecursiveComparisonConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
Stream<Map.Entry<FieldLocation,Comparator<?>>> |
comparatorByFields() |
Comparator<?> |
getComparatorForField(String fieldName) |
Comparator<?> |
getComparatorForType(Class<?> fieldType) |
FieldComparators |
getFieldComparators() |
Set<FieldLocation> |
getIgnoredFields()
Returns the list of the object under test fields to ignore in the recursive comparison.
|
List<Pattern> |
getIgnoredFieldsRegexes() |
List<FieldLocation> |
getIgnoredOverriddenEqualsForFields() |
List<Class<?>> |
getIgnoredOverriddenEqualsForTypes() |
List<Pattern> |
getIgnoredOverriddenEqualsRegexes() |
TypeComparators |
getTypeComparators() |
boolean |
hasComparatorForField(String fieldName) |
boolean |
hasComparatorForType(Class<?> keyType) |
boolean |
hasCustomComparators() |
void |
ignoreAllOverriddenEquals()
Force a recursive comparison on all fields (except java types).
|
void |
ignoreFields(String... fieldsToIgnore)
Adds the given fields to the list of the object under test fields to ignore in the recursive comparison.
|
void |
ignoreFieldsMatchingRegexes(String... regexes)
Allows to ignore in the recursive comparison the object under test fields matching the given regexes.
|
void |
ignoreOverriddenEqualsForFields(String... fields)
Adds the given fields to the list of fields to force a recursive comparison on.
|
void |
ignoreOverriddenEqualsForFieldsMatchingRegexes(String... regexes)
Adds the given regexes to the list of regexes used find the fields to force a recursive comparison on.
|
void |
ignoreOverriddenEqualsForTypes(Class<?>... types)
Adds the given types to the list of types to force a recursive comparison on.
|
boolean |
isInStrictTypeCheckingMode() |
String |
multiLineDescription(Representation representation) |
void |
registerComparatorForField(Comparator<?> comparator,
FieldLocation fieldLocation)
Registers the given
Comparator to compare the fields with the given locations. |
<T> void |
registerComparatorForType(Comparator<? super T> comparator,
Class<T> type)
Registers the given
Comparator to compare the fields with the given type. |
void |
setIgnoreAllActualNullFields(boolean ignoreAllActualNullFields)
Sets whether actual null fields are ignored in the recursive comparison.
|
void |
strictTypeChecking(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).
|
String |
toString() |
public static final String INDENT_LEVEL_2
public boolean hasComparatorForField(String fieldName)
public Comparator<?> getComparatorForField(String fieldName)
public FieldComparators getFieldComparators()
public boolean hasComparatorForType(Class<?> keyType)
public boolean hasCustomComparators()
public Comparator<?> getComparatorForType(Class<?> fieldType)
public TypeComparators getTypeComparators()
public void setIgnoreAllActualNullFields(boolean ignoreAllActualNullFields)
See RecursiveComparisonAssert.ignoringActualNullFields() for code examples.
ignoreAllActualNullFields - whether to ingore actual null fields in the recursive comparisonpublic void ignoreFields(String... fieldsToIgnore)
See RecursiveComparisonAssert#ignoringFields(String...) for examples.
fieldsToIgnore - the fields of the object under test to ignore in the comparison.public void ignoreFieldsMatchingRegexes(String... regexes)
See RecursiveComparisonAssert#ignoringFieldsMatchingRegexes(String...) for examples.
regexes - regexes used to ignore fields in the comparison.public Set<FieldLocation> getIgnoredFields()
public void ignoreAllOverriddenEquals()
See RecursiveComparisonAssert.ignoringAllOverriddenEquals() for examples.
public void ignoreOverriddenEqualsForFields(String... fields)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForFields(String...) for examples.
fields - the fields to force a recursive comparison on.public void ignoreOverriddenEqualsForFieldsMatchingRegexes(String... regexes)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForFieldsMatchingRegexes(String...) for examples.
regexes - regexes used to specify the fields we want to force a recursive comparison on.public void ignoreOverriddenEqualsForTypes(Class<?>... types)
See RecursiveComparisonAssert#ignoringOverriddenEqualsForTypes(Class...) for examples.
types - the types to the list of types to force a recursive comparison on.public <T> void registerComparatorForType(Comparator<? super T> comparator, Class<T> type)
Comparator to compare the fields with the given type.
Comparators specified by this method have less precedence than comparators added with registerComparatorForField(Comparator, FieldLocation).
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.public void registerComparatorForField(Comparator<?> comparator, FieldLocation fieldLocation)
Comparator to compare the fields with the given locations.
The field locations must be specified from the root object,
for example if Foo has a Bar field which has an id, one can register to a comparator for Bar's id by calling:
registerComparatorForField(new FieldLocation("bar.id"), idComparator)
Comparators specified by this method have precedence over comparators added with registerComparatorForType(Comparator, Class).
See RecursiveComparisonAssert#withComparatorForFields(Comparator, String...) for examples.
comparator - the Comparator to use to compare the given fieldfieldLocation - the location from the root object of the field the comparator should be used forpublic void strictTypeChecking(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 boolean isInStrictTypeCheckingMode()
public List<FieldLocation> getIgnoredOverriddenEqualsForFields()
public Stream<Map.Entry<FieldLocation,Comparator<?>>> comparatorByFields()
public String multiLineDescription(Representation representation)
Copyright © 2014–2019 AssertJ. All rights reserved.