Top Description Fields Constructors Methods
org.assertj.core.api.recursive.comparison

public Class ComparingProperties

extends Object
implements RecursiveComparisonIntrospectionStrategy
Class Inheritance
All Implemented Interfaces
org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy
Static Imports
java.util.Arrays.stream, java.util.stream.Collectors.toCollection, .Collectors.toSet, org.assertj.core.util.introspection.ClassUtils.isInJavaLangPackage

A RecursiveComparisonIntrospectionStrategy that introspects properties by looking at public getters like getName() or isActive()/getActive() for boolean properties.

Field Summary

Modifier and TypeField and Description
public static final ComparingProperties
private static final String
private static final String
private final Map<Class<?>, Set<String>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
getChildNodeValue(String
the child node identifier
childNodeName
,
Object
the object to read the child node from
instance
)

Implements org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildNodeValue.

Returns the value of the given object child node, the child node being identified by the childNodeName parameter.
public Set<String>
getChildrenNodeNamesOf(Object
the object to get the child nodes from
node
)

Implements org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildrenNodeNamesOf.

Returns the names of the children nodes of the given object that will be used in the recursive comparison.
public String
getDescription()

Overrides default org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getDescription.

Returns a human-readable description of the strategy to be used in error messages.
pack-priv static Set<String>
public static Set<Method>
private static Set<Method>
gettersOf(Class<?> clazz)

private static boolean
private static boolean
private static boolean
isGetter(Method method)

private static boolean
private static boolean
isStatic(Method method)

private static String
toPropertyName(String methodName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPARING_PROPERTIESback to summary
public static final ComparingProperties COMPARING_PROPERTIES
GET_PREFIXback to summary
private static final String GET_PREFIX
IS_PREFIXback to summary
private static final String IS_PREFIX
propertiesNamesPerClassback to summary
private final Map<Class<?>, Set<String>> propertiesNamesPerClass

Constructor Detail

ComparingPropertiesback to summary
public ComparingProperties()

Method Detail

getChildNodeValueback to summary
public Object getChildNodeValue(String childNodeName, Object instance)

Implements org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildNodeValue.

Doc from org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildNodeValue.

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.

Parameters
childNodeName:String

the child node identifier

instance:Object

the object to read the child node from

Returns:Object

the object child node value

Annotations
@Override
getChildrenNodeNamesOfback to summary
public Set<String> getChildrenNodeNamesOf(Object node)

Implements org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildrenNodeNamesOf.

Doc from org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getChildrenNodeNamesOf.

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.

Parameters
node:Object

the object to get the child nodes from

Returns:Set<String>

the names of the children nodes of the given object

Annotations
@Override
getDescriptionback to summary
public String getDescription()

Overrides default org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getDescription.

Doc from org.assertj.core.api.recursive.comparison.RecursiveComparisonIntrospectionStrategy.getDescription.

Returns a human-readable description of the strategy to be used in error messages.

The default implementation returns this.getClass().getSimpleName().

Returns:String

a description of the strategy

Annotations
@Override
getPropertiesNamesOfback to summary
pack-priv static Set<String> getPropertiesNamesOf(Class<?> clazz)
gettersIncludingInheritedOfback to summary
public static Set<Method> gettersIncludingInheritedOf(Class<?> clazz)
gettersOfback to summary
private static Set<Method> gettersOf(Class<?> clazz)
hasParametersback to summary
private static boolean hasParameters(Method method)
isBooleanPropertyback to summary
private static boolean isBooleanProperty(Method method)
isGetterback to summary
private static boolean isGetter(Method method)
isRegularGetterback to summary
private static boolean isRegularGetter(Method method)
isStaticback to summary
private static boolean isStatic(Method method)
toPropertyNameback to summary
private static String toPropertyName(String methodName)