Top Description Fields Constructors Methods
org.assertj.core.api.recursive.comparison

public Class ComparingSnakeOrCamelCaseFields

extends ComparingNormalizedFields
Class Inheritance
Static Imports
java.lang.Character.isUpperCase, org.assertj.core.util.introspection.CaseFormatUtils.toCamelCase

A RecursiveComparisonIntrospectionStrategy that transforms snake case field names into camel case.

The normalization also normalize uppercase acronyms by keeping only the first acronym letter uppercase so that profile_url and profileURL can be matched, both being normalized to profileUrl.

Since
3.24.0

Field Summary

Modifier and TypeField and Description
public static final ComparingSnakeOrCamelCaseFields

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
private static String

Returns:

the normalized name
normalizeAcronyms
(String
the name to normalize
name
)

Normalizes uppercase acronyms by keeping only the first acronym letter uppercase, ex: normalizeAcronyms("URl") gives "Url"

public String

Returns:

camel case version of the field name
normalizeFieldName
(String
the field name to normalize
name
)

Implements abstract org.assertj.core.api.recursive.comparison.ComparingNormalizedFields.normalizeFieldName.

Transforms snake case field names into camel case (leave camel case fields as is).
Inherited from org.assertj.core.api.recursive.comparison.ComparingNormalizedFields:
getChildNodeValuegetChildrenNodeNamesOf

Field Detail

COMPARING_SNAKE_OR_CAMEL_CASE_FIELDSback to summary
public static final ComparingSnakeOrCamelCaseFields COMPARING_SNAKE_OR_CAMEL_CASE_FIELDS

Constructor Detail

ComparingSnakeOrCamelCaseFieldsback to summary
public ComparingSnakeOrCamelCaseFields()

Method Detail

getDescriptionback to summary
public String getDescription()

Overrides org.assertj.core.api.recursive.comparison.ComparingNormalizedFields.getDescription.

Overrides default org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getDescription.

Doc from org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getDescription.

Returns a human-readable description of the strategy to be used in error messages.

The default implementation returns this.getClass().getSimpleName().

Returns:String

a description of the strategy

Annotations
@Override
normalizeAcronymsback to summary
private static String normalizeAcronyms(String name)

Normalizes uppercase acronyms by keeping only the first acronym letter uppercase, ex: normalizeAcronyms("URl") gives "Url"

Parameters
name:String

the name to normalize

Returns:String

the normalized name

normalizeFieldNameback to summary
public String normalizeFieldName(String name)

Implements abstract org.assertj.core.api.recursive.comparison.ComparingNormalizedFields.normalizeFieldName.

Transforms snake case field names into camel case (leave camel case fields as is).

For example, this allows to compare Person object with camel case fields like firstName to a PersonDto object with snake case fields like first_name.

Parameters
name:String

the field name to normalize

Returns:String

camel case version of the field name

Annotations
@Override