dimanche 19 avril 2015

How to know property value if in runtime I have reference to bean instance and property name?

I have following bean



class MyBean{
Date myDate;
String anotherProperty;
...
}


and following method:



public static Date getDateField(MyBean instance, String propertyName){
...
}


I want to invoke following method like this:



getDateField(myBeanInstance, "myDate")


I am feel that it is possible to achieve but I have not ideas how to realize getDateField method.






Aucun commentaire:

Enregistrer un commentaire