mardi 11 octobre 2016

Java Reflection : Accessing getter method

The code

import java.beans.*
for (PropertyDescriptor pd : Introspector.getBeanInfo(Foo.class).getPropertyDescriptors()) {
    if (pd.getReadMethod() != null && !"class".equals(pd.getName()))
        System.out.println(pd.getReadMethod().invoke(foo));
}

This code returns the getters of the class but I am trying to access the getters in the order of attributes where I can set their values to.

How can I access the getters in particualr order?





Aucun commentaire:

Enregistrer un commentaire