mercredi 6 mai 2015

Java Reflection - get the name of a field from a set method

i started to work with java reflection I started to create my own personal working methods, including a method that takes all the setter of a class. Now I find myself in the bizarre situation of wanting to take the name of the field of methods set, i try to make myself more clear with a example:

private String urla;
public setUrl(String urlb){
   this.urla = urlb;
}

I have now a method for get the Method "setUrl" and i want create a method for take the field of the set method that is initialized from it, like this:

Mehtod method = getSetter(); //return method setUrl
String nameField = getFieldFromSetter(method) //return "urla"

You think it's possible? ty in advance.





Aucun commentaire:

Enregistrer un commentaire