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
ARecursiveComparisonIntrospectionStrategythat 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_urlandprofileURLcan be matched, both being normalized toprofileUrl.- Since:
- 3.24.0
-
-
Field Summary
Fields Modifier and Type Field Description static ComparingSnakeOrCamelCaseFieldsCOMPARING_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.StringgetDescription()Returns a human-readable description of the strategy to be used in error messages.private static java.lang.StringnormalizeAcronyms(java.lang.String name)Normalizes uppercase acronyms by keeping only the first acronym letter uppercase, ex:normalizeAcronyms("URl")gives"Url"java.lang.StringnormalizeFieldName(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
Personobject with camel case fields likefirstNameto aPersonDtoobject with snake case fields likefirst_name.- Specified by:
normalizeFieldNamein 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:RecursiveComparisonIntrospectionStrategyReturns a human-readable description of the strategy to be used in error messages.The default implementation returns
this.getClass().getSimpleName().- Specified by:
getDescriptionin interfaceRecursiveComparisonIntrospectionStrategy- Overrides:
getDescriptionin classComparingNormalizedFields- Returns:
- a description of the strategy
-
-