Class ComparingProperties
- java.lang.Object
-
- org.assertj.core.api.recursive.comparison.ComparingProperties
-
- All Implemented Interfaces:
RecursiveComparisonIntrospectionStrategy
public class ComparingProperties extends java.lang.Object implements RecursiveComparisonIntrospectionStrategy
ARecursiveComparisonIntrospectionStrategythat introspects properties by looking at public getters likegetName()orisActive()/getActive()for boolean properties.
-
-
Field Summary
Fields Modifier and Type Field Description static ComparingPropertiesCOMPARING_PROPERTIESprivate static java.lang.StringGET_PREFIXprivate static java.lang.StringIS_PREFIXprivate java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>>propertiesNamesPerClass
-
Constructor Summary
Constructors Constructor Description ComparingProperties()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetChildNodeValue(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.java.lang.StringgetDescription()Returns a human-readable description of the strategy to be used in error messages.(package private) static java.util.Set<java.lang.String>getPropertiesNamesOf(java.lang.Class<?> clazz)static java.util.Set<java.lang.reflect.Method>gettersIncludingInheritedOf(java.lang.Class<?> clazz)private static java.util.Set<java.lang.reflect.Method>gettersOf(java.lang.Class<?> clazz)private static booleanhasParameters(java.lang.reflect.Method method)private static booleanisBooleanProperty(java.lang.reflect.Method method)private static booleanisGetter(java.lang.reflect.Method method)private static booleanisRegularGetter(java.lang.reflect.Method method)private static booleanisStatic(java.lang.reflect.Method method)private static java.lang.StringtoPropertyName(java.lang.String methodName)
-
-
-
Field Detail
-
COMPARING_PROPERTIES
public static final ComparingProperties COMPARING_PROPERTIES
-
GET_PREFIX
private static final java.lang.String GET_PREFIX
- See Also:
- Constant Field Values
-
IS_PREFIX
private static final java.lang.String IS_PREFIX
- See Also:
- Constant Field Values
-
propertiesNamesPerClass
private final java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> propertiesNamesPerClass
-
-
Method Detail
-
getChildrenNodeNamesOf
public java.util.Set<java.lang.String> getChildrenNodeNamesOf(java.lang.Object node)
Description copied from interface:RecursiveComparisonIntrospectionStrategyReturns 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:
getChildrenNodeNamesOfin 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:RecursiveComparisonIntrospectionStrategyReturns 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:
getChildNodeValuein interfaceRecursiveComparisonIntrospectionStrategy- Parameters:
childNodeName- the child node identifierinstance- the object to read the child node from- Returns:
- the object child node value
-
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- Returns:
- a description of the strategy
-
getPropertiesNamesOf
static java.util.Set<java.lang.String> getPropertiesNamesOf(java.lang.Class<?> clazz)
-
toPropertyName
private static java.lang.String toPropertyName(java.lang.String methodName)
-
gettersIncludingInheritedOf
public static java.util.Set<java.lang.reflect.Method> gettersIncludingInheritedOf(java.lang.Class<?> clazz)
-
gettersOf
private static java.util.Set<java.lang.reflect.Method> gettersOf(java.lang.Class<?> clazz)
-
isStatic
private static boolean isStatic(java.lang.reflect.Method method)
-
isGetter
private static boolean isGetter(java.lang.reflect.Method method)
-
isRegularGetter
private static boolean isRegularGetter(java.lang.reflect.Method method)
-
hasParameters
private static boolean hasParameters(java.lang.reflect.Method method)
-
isBooleanProperty
private static boolean isBooleanProperty(java.lang.reflect.Method method)
-
-