I have several data classes in java of which I want to know - using reflection - which fields have a certain annotation with a certain attribute which is the following:
@Column(columnDefinition = "text") // Text with unbound length
private String comment;
I figured how to get the annotations of the field and whether it is of type Column
:
private boolean isStringFieldWithBoundLength(Field attr) {
Annotation[] annotations = attr.getDeclaredAnnotations();
for (Annotation ann : annotations) {
Class<? extends Annotation> aClass = ann.annotationType();
if (Column.class == aClass) {
// ...
}
}
}
Now in the debugger I can see that the aClass
object has the information about the provided parameters. Unfortunately I don't know how to access it with code. Is it possible to access this information in java?
Aucun commentaire:
Enregistrer un commentaire