Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I find myself repeatedly searching for fields (or methods) that are annotated with a specified annotation like this (field-only example):
List<Field> fieldsWithAnnotation = new ArrayList<>(); Field[] fields = FieldUtils.getAllFields(type); for (Field field : fields) { Annotation fieldAnnotation = field.getAnnotation(annotation); if (fieldAnnotation != null) { fieldsWithAnnotation.add(fieldAnnotation); } }
Commons Lang could provide these methods:
public Field[] AnnotationUtils.getFieldsWithAnnotation(Annotation annotation); public List<Field> AnnotationUtils.getFieldListWithAnnotation(Annotation annotation); public Method[] AnnotationUtils.getMethodsWithAnnotation(Annotation annotation); public List<Method> AnnotationUtils.getMethodListWithAnnotation(Annotation annotation);