Problem Statement:
Imagine a nested object like below:
class Company{
...
List<Department> departments;
}
class Department{
...
List<Employee> employees;
}
class Employee{
String name;
...
}
A company has many departments, and each department has many employees.
Json body is unmarshalled by a library, to create the Java object Company as shown above.
Suppose I had an employee with name:"John", I am looking for an api, which when I pass in the hash of Employee object or the attribute name returns a Path to that attribute.
search(Object attributeName, Object attributeValue) i.e search("name", "John") should return company.departments[0].employees[5]
Is there a good open source library exposing similar api or what is the best method around to walk over a complex object graph
JSR 303 Hibernate Validator, which adds property path automatically to a ConstraintViolation doesn't expose the behavior on how it gets property path from complex object graphs via any object
Kindly advice if anyone has run through a similar need