Is there any open source utility or jar for handling reflection in java?
I am passing methods Dynamically to a class and I would like to fetch the return value.
For Example:
class Department {
String name ;
Employee[] employees;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public Employee[] getEmployes() {
return employees;
}
}
I would like to print all the employees to the console output but instead getting it at run-time like this:
Department dept = new Department();
// add employees..
getEmployeeNames(dept,"getEmployees.getAddress.getStreet");
// So the user says they want employee street, but we don't know that
// until run-tme.
Is there any opensource on reflection to accommodate something like this?
getEmployes()
returns an array? There will be no methodgetAddress()
on an[]
..