I need to check if there is an annotation present at a Field
, but I can't use isAnnotationPresent
to check it.
public void foo(Class<?> clazz) {
Field[] fieldReflection = clazz.getDeclaredFields();
for (Field fieldReflect : fieldReflection){
if (fieldReflect.isAnnotationPresent(FieldSize.class){
//do something
} else {
throw new Exception();
}
}
}
This is how I'm doing today, there is another way to check if the Field
have an annotation?
Aucun commentaire:
Enregistrer un commentaire