Class ComparingSnakeOrCamelCaseFields
- java.lang.Object
-
- org.assertj.core.api.recursive.comparison.ComparingNormalizedFields
-
- org.assertj.core.api.recursive.comparison.ComparingSnakeOrCamelCaseFields
-
- All Implemented Interfaces:
RecursiveComparisonIntrospectionStrategy
public class ComparingSnakeOrCamelCaseFields extends ComparingNormalizedFields
ARecursiveComparisonIntrospectionStrategy
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
andprofileURL
can be matched, both being normalized toprofileUrl
.- Since:
- 3.24.0
-
-
Field Summary
Fields Modifier and Type Field Description static ComparingSnakeOrCamelCaseFields
COMPARING_SNAKE_OR_CAMEL_CASE_FIELDS
-
Constructor Summary
Constructors Constructor Description ComparingSnakeOrCamelCaseFields()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDescription()
Returns a human-readable description of the strategy to be used in error messages.private static java.lang.String
normalizeAcronyms(java.lang.String name)
Normalizes uppercase acronyms by keeping only the first acronym letter uppercase, ex:normalizeAcronyms("URl")
gives"Url"
java.lang.String
normalizeFieldName(java.lang.String name)
Transforms snake case field names into camel case (leave camel case fields as is).-
Methods inherited from class org.assertj.core.api.recursive.comparison.ComparingNormalizedFields
getChildNodeValue, getChildrenNodeNamesOf
-
-
-
-
Field Detail
-
COMPARING_SNAKE_OR_CAMEL_CASE_FIELDS
public static final ComparingSnakeOrCamelCaseFields COMPARING_SNAKE_OR_CAMEL_CASE_FIELDS
-
-
Method Detail
-
normalizeFieldName
public java.lang.String normalizeFieldName(java.lang.String name)
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 likefirstName
to aPersonDto
object with snake case fields likefirst_name
.- Specified by:
normalizeFieldName
in classComparingNormalizedFields
- Parameters:
name
- the field name to normalize- Returns:
- camel case version of the field name
-
normalizeAcronyms
private static java.lang.String normalizeAcronyms(java.lang.String name)
Normalizes uppercase acronyms by keeping only the first acronym letter uppercase, ex:normalizeAcronyms("URl")
gives"Url"
- Parameters:
name
- the name to normalize- Returns:
- the normalized name
-
getDescription
public java.lang.String getDescription()
Description copied from interface:RecursiveComparisonIntrospectionStrategy
Returns a human-readable description of the strategy to be used in error messages.The default implementation returns
this.getClass().getSimpleName()
.- Specified by:
getDescription
in interfaceRecursiveComparisonIntrospectionStrategy
- Overrides:
getDescription
in classComparingNormalizedFields
- Returns:
- a description of the strategy
-
-