I'm using the method below to get the names of all getter methods of a class:
private static Map<String, Object> fetchGetterMethods(Object object) {
Map<String, Object> result = new HashMap<String, Object>();
BeanInfo info;
try {
info = Introspector.getBeanInfo(object.getClass());
for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
Method reader = pd.getReadMethod();
if (reader != null) {
String name = pd.getName();
if (!"class".equals(name)) {
try {
Object value = reader.invoke(object);
result.put(name, value);
} catch (Exception e) {
}
}
}
}
} catch (IntrospectionException e) {
} finally {
return result;
}
}
I would like to skip the getter methods annotated with @Transient. How can I implement this?
@Transient
public boolean isValid() {
}