Can we find setter method name using property name?
I have a dynamically generated map<propertyName,propertyValue>
By using the key from map (which is propertyName) I need to invoke the appropriate setter method for object and pass the value from map (which is propertyValue).
class A {
String name;
String age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
}
My map contain two items:
map<"name","jack">
map<"company","inteld">
Now I am iterating the map and as I proceed with each item from map, based on key (either name or company) I need to call appropriate setter method of class A e.g. for first item I get name as key so need to call new A().setName.