Class DefaultRecursiveComparisonIntrospectionStrategy
- java.lang.Object
-
- org.assertj.core.api.recursive.comparison.DefaultRecursiveComparisonIntrospectionStrategy
-
- All Implemented Interfaces:
RecursiveComparisonIntrospectionStrategy
public class DefaultRecursiveComparisonIntrospectionStrategy extends java.lang.Object implements RecursiveComparisonIntrospectionStrategy
Introspects all fields (including inherited ones) and get their value according toPropertyOrFieldSupport.getSimpleValue(String, Object)
.There is a bit of discrepancy in this strategy as it looks for fields to compare but gets the value in this order: property first, then field and finally tries as map value if the instance is a map.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>>
fieldNamesPerClass
-
Constructor Summary
Constructors Constructor Description DefaultRecursiveComparisonIntrospectionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getChildNodeValue(java.lang.String childNodeName, java.lang.Object instance)
Returns the value of the given object child node, the child node being identified by the childNodeName parameter.java.util.Set<java.lang.String>
getChildrenNodeNamesOf(java.lang.Object node)
Returns the names of the children nodes of the given object that will be used in the recursive comparison.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy
getDescription
-
-
-
-
Method Detail
-
getChildrenNodeNamesOf
public java.util.Set<java.lang.String> getChildrenNodeNamesOf(java.lang.Object node)
Description copied from interface:RecursiveComparisonIntrospectionStrategy
Returns the names of the children nodes of the given object that will be used in the recursive comparison.A typical implementation could look at the object fields or properties.
- Specified by:
getChildrenNodeNamesOf
in interfaceRecursiveComparisonIntrospectionStrategy
- Parameters:
node
- the object to get the child nodes from- Returns:
- the names of the children nodes of the given object
-
getChildNodeValue
public java.lang.Object getChildNodeValue(java.lang.String childNodeName, java.lang.Object instance)
Description copied from interface:RecursiveComparisonIntrospectionStrategy
Returns the value of the given object child node, the child node being identified by the childNodeName parameter.It's the implementor choice how to resolve the child node value, a typical implementation consists of considering childNodeName to be a field name and then use introspection to read the field value, but if the object is a Map the implementation could consider the child node name to be a key of the map.
- Specified by:
getChildNodeValue
in interfaceRecursiveComparisonIntrospectionStrategy
- Parameters:
childNodeName
- the child node identifierinstance
- the object to read the child node from- Returns:
- the object child node value
-
-