mercredi 30 mars 2022

How can I get class object value if given a variable in the form of a string

I have a class

@lombok
class a {
private String status;
}

and I have a method that accepts a string value

public string getValue (String input, Class a) {
//  Let's say input value is status
   return a.getStatus();
}
````
How can I return a.getStatus()?

I'm not able to figure out a way to map these values with and without using reflection.

I can change status to getStatus as well in the input if it helps.




Aucun commentaire:

Enregistrer un commentaire