我有几个java数据类,我想知道这些数据类使用反射,哪些字段具有具有特定属性的特定注释,如下所示:
@Column(columnDefinition = "text") // Text with unbound length
private String comment;
我计算了如何获取字段的注释,以及它是否为Column
类型:
private boolean isStringFieldWithBoundLength(Field attr) {
Annotation[] annotations = attr.getDeclaredAnnotations();
for (Annotation ann : annotations) {
Class<? extends Annotation> aClass = ann.annotationType();
if (Column.class == aClass) {
// ...
}
}
}
现在在调试器中,我可以看到aClass
对象具有有关所提供参数的信息.不幸的是,我不知道如何用代码访问它.是否可以用java访问此信息?