RecursiveComparisonIntrospectionStrategy that introspects fields provided their normalized name.
Subclass this and simply provide the normalization to apply by implementing normalizeFieldName(String).
It is recommended to override getDescription() to get more informative error messages.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final String | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the object field valuethe field name fieldName, Object the object to read the field from instance)Implements org. |
| public Set | Returns: the normalized names of the children nodes of the given objectthe object to get the child nodes from node)Implements org. |
| public String | getDescription()
Overrides default org. |
| private String | |
| private String | |
| protected abstract String | Returns: the normalized field namethe field name to normalize fieldName)Returns the normalized version of the given field name to allow actual and expected fields to be matched. |
| fieldNamesPerClass | back to summary |
|---|---|
| private final Map<Class<?>, Set<String>> fieldNamesPerClass | |
| NO_FIELD_FOUND | back to summary |
|---|---|
| private static final String NO_FIELD_FOUND | |
| originalFieldNamesByNormalizedFieldNameByNode | back to summary |
|---|---|
| private final Map<Object, Map<String, String>> originalFieldNamesByNormalizedFieldNameByNode | |
| ComparingNormalizedFields | back to summary |
|---|---|
| public ComparingNormalizedFields() | |
| getChildNodeValue | back to summary |
|---|---|
| public Object getChildNodeValue(String fieldName, Object instance) Implements org. Returns the value of the given object field identified by the fieldName parameter.
Note that this method receives the normalized field name with (see
For example, let's assume | |
| getChildrenNodeNamesOf | back to summary |
|---|---|
| public Set Implements org. Returns the normalized names of the children nodes of the given object that will be used in the recursive comparison.
The names are normalized according to | |
| getDescription | back to summary |
|---|---|
| public String getDescription() Overrides default org. Doc from org. Returns a human-readable description of the strategy to be used in error messages.
The default implementation returns | |
| getOriginalFieldName | back to summary |
|---|---|
| private String getOriginalFieldName(String fieldName, Object instance) | |
| normalize | back to summary |
|---|---|
| private String normalize(Object node, String fieldName) Normalize the field name and keep track of the normalized name -> original name | |
| normalizeFieldName | back to summary |
|---|---|
| protected abstract String normalizeFieldName(String fieldName) Returns the normalized version of the given field name to allow actual and expected fields to be matched.
For example, let's assume
The default recursive comparison gathers all In our example, we can either normalize fields to be camel case or snake case (camel case would be more natural though).
Note that | |