Top Inners Fields Constructors Methods
org.assertj.core.api.recursive

public abstract Class AbstractRecursiveOperationConfiguration

extends Object
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration, org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration
Static Imports
java.lang.String.format, java.util.Arrays.stream, java.util.stream.Collectors.toList, org.assertj.core.util.Lists.list

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
protected static final String
private final Set<String>
private final List<Pattern>
private final Set<Class<?>>
private final List<Pattern>

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
protected static Class<?>
protected void
private String
protected void
protected String
protected String
public Set<String>

Returns:

the set of fields from the object under test to ignore in the recursive comparison.
getIgnoredFields
()

Returns the set of fields from the object under test to ignore in the recursive comparison.

public List<Pattern>
public Set<Class<?>>

Returns:

the set of fields from the object under test types to ignore in the recursive comparison.
getIgnoredTypes
()

Returns the set of fields from the object under test types to ignore in the recursive comparison.

public List<Pattern>

Returns:

the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.
getIgnoredTypesRegexes
()

Returns the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.

public void
ignoreFields(String...
the fields of the object under test to ignore in the comparison.
fieldsToIgnore
)

Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.

public void
ignoreFieldsMatchingRegexes(String...
regexes used to ignore fields in the comparison.
regexes
)

Allows to ignore in the recursive comparison the object under test fields matching the given regexes.

public void
ignoreFieldsOfTypes(Class<?>...
the types of the object under test to ignore in the comparison.
types
)

Makes the recursive assertion to ignore the object under test fields of the given types.

public void
ignoreFieldsOfTypesMatchingRegexes(String...
regexes specifying the types to ignore.
regexes
)

Makes the recursive comparison to ignore the fields of the object under test having types matching one of the given regexes.

protected static String
join(Collection<String> typesDescription)

public boolean
public boolean
private static List<Pattern>
toPatterns(String[] regexes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_DELIMITERback to summary
protected static final String DEFAULT_DELIMITER
ignoredFieldsback to summary
private final Set<String> ignoredFields
ignoredFieldsRegexesback to summary
private final List<Pattern> ignoredFieldsRegexes
ignoredTypesback to summary
private final Set<Class<?>> ignoredTypes
ignoredTypesRegexesback to summary
private final List<Pattern> ignoredTypesRegexes

Constructor Detail

AbstractRecursiveOperationConfigurationback to summary
protected AbstractRecursiveOperationConfiguration(AbstractRecursiveOperationConfiguration.AbstractBuilder<?> builder)
AbstractRecursiveOperationConfigurationback to summary
protected AbstractRecursiveOperationConfiguration()

Method Detail

asWrapperIfPrimitiveTypeback to summary
protected static Class<?> asWrapperIfPrimitiveType(Class<?> type)
describeIgnoredFieldsback to summary
protected void describeIgnoredFields(StringBuilder description)
describeIgnoredFieldsback to summary
private String describeIgnoredFields()
describeIgnoredFieldsRegexesback to summary
protected void describeIgnoredFieldsRegexes(StringBuilder description)
describeIgnoredTypesback to summary
protected String describeIgnoredTypes()
describeRegexesback to summary
protected String describeRegexes(List<Pattern> regexes)
getIgnoredFieldsback to summary
public Set<String> getIgnoredFields()

Returns the set of fields from the object under test to ignore in the recursive comparison.

Returns:Set<String>

the set of fields from the object under test to ignore in the recursive comparison.

getIgnoredFieldsRegexesback to summary
public List<Pattern> getIgnoredFieldsRegexes()
getIgnoredTypesback to summary
public Set<Class<?>> getIgnoredTypes()

Returns the set of fields from the object under test types to ignore in the recursive comparison.

Returns:Set<Class<?>>

the set of fields from the object under test types to ignore in the recursive comparison.

getIgnoredTypesRegexesback to summary
public List<Pattern> getIgnoredTypesRegexes()

Returns the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.

Returns:List<Pattern>

the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.

ignoreFieldsback to summary
public void ignoreFields(String... fieldsToIgnore)

Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.

The fields are ignored by name, not by value.

See RecursiveComparisonAssert#ignoringFields(String...) for examples.

Parameters
fieldsToIgnore:String[]

the fields of the object under test to ignore in the comparison.

ignoreFieldsMatchingRegexesback to summary
public void ignoreFieldsMatchingRegexes(String... regexes)

Allows to ignore in the recursive comparison the object under test fields matching the given regexes. The given regexes are added to the already registered ones.

See RecursiveComparisonAssert#ignoringFieldsMatchingRegexes(String...) for examples.

Parameters
regexes:String[]

regexes used to ignore fields in the comparison.

ignoreFieldsOfTypesback to summary
public void ignoreFieldsOfTypes(Class<?>... types)

Makes the recursive assertion to ignore the object under test fields of the given types. The fields are ignored if their types exactly match one of the ignored types, for example if a field is a subtype of an ignored type it is not ignored.

If some object under test fields are null it is not possible to evaluate their types and thus these fields are not ignored.

Example: see RecursiveComparisonAssert#ignoringFieldsOfTypes(Class[]).

Parameters
types:Class<?>[]

the types of the object under test to ignore in the comparison.

ignoreFieldsOfTypesMatchingRegexesback to summary
public void ignoreFieldsOfTypesMatchingRegexes(String... regexes)

Makes the recursive comparison to ignore the fields of the object under test having types matching one of the given regexes. The fields are ignored if their types exactly match one of the regexes, if a field is a subtype of a matched type it is not ignored.

One use case of this method is to ignore types that can't be introspected.

If strictTypeChecking mode is enabled and a field of the object under test is null, the recursive comparison evaluates the corresponding expected field's type (if not null), if it is disabled then the field is evaluated as usual (i.e. it is not ignored).

Warning

primitive types are not directly supported because under the hood they are converted to their corresponding wrapping types, for example int to java.lang.Integer. The preferred way to ignore primitive types is to use ignoreFieldsOfTypes(Class[]). Another way is to ignore the wrapping type, for example ignoring java.lang.Integer ignores both java.lang.Integer and int fields.

Example: see RecursiveComparisonAssert#ignoringFieldsOfTypesMatchingRegexes(String...).

Parameters
regexes:String[]

regexes specifying the types to ignore.

joinback to summary
protected static String join(Collection<String> typesDescription)
matchesAnIgnoredFieldback to summary
public boolean matchesAnIgnoredField(FieldLocation fieldLocation)
matchesAnIgnoredFieldRegexback to summary
public boolean matchesAnIgnoredFieldRegex(FieldLocation fieldLocation)
toPatternsback to summary
private static List<Pattern> toPatterns(String[] regexes)
org.assertj.core.api.recursive back to summary

protected Class AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE extends AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE>>

extends Object
Class Inheritance
  • java.lang.Object
  • org.assertj.core.api.recursive.AbstractRecursiveOperationConfiguration.AbstractBuilder
Known Direct Subclasses
org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.Builder, org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration.Builder

Field Summary

Modifier and TypeField and Description
private String[]
private String[]
private Class<?>[]
private final BUILDER_TYPE

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public BUILDER_TYPE

Returns:

this builder.
withIgnoredFields
(String...
the fields of the object under test to ignore in the comparison.
fieldsToIgnore
)

Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.

public BUILDER_TYPE

Returns:

this builder.
withIgnoredFieldsMatchingRegexes
(String...
regexes used to ignore fields in the comparison.
regexes
)

Allows to ignore in the recursive comparison the object under test fields matching the given regexes.

public BUILDER_TYPE

Returns:

this builder.
withIgnoredFieldsOfTypes
(Class<?>...
the types of the object under test to ignore in the comparison.
types
)

Adds the given types to the list fields from the object under test types to ignore in the recursive comparison.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ignoredFieldsback to summary
private String[] ignoredFields
ignoredFieldsMatchingRegexesback to summary
private String[] ignoredFieldsMatchingRegexes
ignoredTypesback to summary
private Class<?>[] ignoredTypes
thisBuilderback to summary
private final BUILDER_TYPE thisBuilder

Constructor Detail

AbstractBuilderback to summary
protected AbstractBuilder(Class<? extends AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE>> selfType)
Annotations
@SuppressWarnings:unchecked

Method Detail

withIgnoredFieldsback to summary
public BUILDER_TYPE withIgnoredFields(String... fieldsToIgnore)

Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison. Nested fields can be specified like this: home.address.street.

See RecursiveComparisonAssert#ignoringFields(String...) for examples.

Parameters
fieldsToIgnore:String[]

the fields of the object under test to ignore in the comparison.

Returns:BUILDER_TYPE

this builder.

withIgnoredFieldsMatchingRegexesback to summary
public BUILDER_TYPE withIgnoredFieldsMatchingRegexes(String... regexes)

Allows to ignore in the recursive comparison the object under test fields matching the given regexes. The given regexes are added to the already registered ones.

See RecursiveComparisonAssert#ignoringFieldsMatchingRegexes(String...) for examples.

Parameters
regexes:String[]

regexes used to ignore fields in the comparison.

Returns:BUILDER_TYPE

this builder.

withIgnoredFieldsOfTypesback to summary
public BUILDER_TYPE withIgnoredFieldsOfTypes(Class<?>... types)

Adds the given types to the list fields from the object under test types to ignore in the recursive comparison. The fields are ignored if their types exactly match one of the ignored types, if a field is a subtype of an ignored type it won't be ignored.

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.

Parameters
types:Class<?>[]

the types of the object under test to ignore in the comparison.

Returns:BUILDER_TYPE

this builder.