Description
The RecursiveObjectReader class allows you to examine the properties of an object (property instrospection) and to dynamically read them recursively using “dot” notation (e.g property.property.method).
Important points
- It is similar to ObjectReader but reads properties recursively through the entire object graph.
- Nested property names are defined using dot notation as “object.subobject.property”.
Static methods
getProperties
Gets the values of all properties in a specified object and its subobjects and returns them as a map.
The object can be a user defined object, map or array. Returned properties correspondently are object’s properties, map key-pairs or array elements with their indexes.
public static
Map<String, Object> getProperties(Object obj)
- obj: Object - object to get properties from.
- returns: Map<String, Object> - map containing the names of the object’s properties and their values.
getProperty
Recursively gets the value of an object’s or its subobjects' property specified by its name.
The object can be a user defined object, map or array. The property name correspondently must be an object’s property, map key or array index.
public static
Object getProperty(Object obj, String name)
- obj: Object - object to read the property from.
- name: String - name of the property to get.
- returns: Object - property value or null if the property doesn’t exist or introspection failed.
getPropertyNames
Recursively gets the names of all properties implemented in a specified object and its subobjects.
The object can be a user defined object, map or array. Returned property name correspondently are object’s properties, map keys or array indexes.
public static
ListgetPropertyNames(Object obj)
- obj: Object - objec to introspect.
- returns: List
- list with property names.
hasProperty
public static
hasPropertboolean hasProperty(Object obj, String name)
- obj: Object - object to introspect.
- name: String - name of the property to check.
- returns: boolean - true if the object has the property and false if it doesn’t.