Class RecursiveObjectReader
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"
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetProperties
(Object obj) Get values of all properties in specified object and its subobjects and returns them as a map.static Object
getProperty
(Object obj, String name) Recursively gets value of object or its subobjects property specified by its name.getPropertyNames
(Object obj) Recursively gets names of all properties implemented in specified object and its subobjects.static boolean
hasProperty
(Object obj, String name) Checks recursively if object or its subobjects has a property with specified name.
-
Constructor Details
-
RecursiveObjectReader
public RecursiveObjectReader()
-
-
Method Details
-
hasProperty
Checks recursively if object or its subobjects has a property with specified name.The object can be a user defined object, map or array. The property name correspondently must be object property, map key or array index.
- Parameters:
obj
- an object to introspect.name
- a name of the property to check.- Returns:
- true if the object has the property and false if it doesn't.
-
getProperty
Recursively gets value of object 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 object property, map key or array index.
- Parameters:
obj
- an object to read property from.name
- a name of the property to get.- Returns:
- the property value or null if property doesn't exist or introspection failed.
-
getPropertyNames
Recursively gets names of all properties implemented in specified object and its subobjects.The object can be a user defined object, map or array. Returned property name correspondently are object properties, map keys or array indexes.
- Parameters:
obj
- an objec to introspect.- Returns:
- a list with property names.
-
getProperties
Get values of all properties in 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 properties, map key-pairs or array elements with their indexes.
- Parameters:
obj
- an object to get properties from.- Returns:
- a map, containing the names of the object's properties and their values.
-