Class ComparingProperties

java.lang.Object
org.assertj.core.api.recursive.comparison.ComparingProperties
All Implemented Interfaces:
RecursiveComparisonIntrospectionStrategy

public class ComparingProperties extends Object implements RecursiveComparisonIntrospectionStrategy
A RecursiveComparisonIntrospectionStrategy that introspects properties by looking at public getters like getName() or isActive()/getActive() for boolean properties.
  • Field Details

  • Constructor Details

    • ComparingProperties

      public ComparingProperties()
  • Method Details

    • getChildrenNodeNamesOf

      public Set<String> getChildrenNodeNamesOf(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 interface RecursiveComparisonIntrospectionStrategy
      Parameters:
      node - the object to get the child nodes from
      Returns:
      the names of the children nodes of the given object
    • getChildNodeValue

      public Object getChildNodeValue(String childNodeName, 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 interface RecursiveComparisonIntrospectionStrategy
      Parameters:
      childNodeName - the child node identifier
      instance - the object to read the child node from
      Returns:
      the object child node value
    • getDescription

      public 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 interface RecursiveComparisonIntrospectionStrategy
      Returns:
      a description of the strategy
    • gettersIncludingInheritedOf

      public static Set<Method> gettersIncludingInheritedOf(Class<?> clazz)