I want to find all the fields of a given class if an annotation is stored at either the:
Here are some examples:
@Audited
static class AnnotatedClassIn {
private Long statusCode;
public Long getStatusCode() {
return statusCode;
}
public void setStatusCode(Long statusCode) {
this.statusCode = statusCode;
}
}
static class AnnotatedClassOut {
@Audited
private String statusCode;
private String statusDesc;
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getStatusDesc() {
return statusDesc;
}
public void setStatusDesc(String statusDesc) {
this.statusDesc = statusDesc;
}
}
I would expect both of these to report statusCode.
My first attempt was this:
Set<Field> fields = getAllFields(object.getClass(), withAnnotation(Audited.class));
Which worked for the 2nd case, but reported no fields for the first. Is this possible?