[
https://issues.apache.org/jira/browse/LANG-1021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14067865#comment-14067865
]
Benedikt Ritter commented on LANG-1021:
---------------------------------------
{code}
bene@Benedikts-MacBook-Pro:~/workspace/apache/commons/lang$ svn ci -m
"LANG-1021: Provide methods to retrieve all fields/methods annotated with a
specific type. Thanks to Alexander Müller."
Sending src/changes/changes.xml
Sending src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
Sending src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
Sending
src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
Sending
src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
Adding
src/test/java/org/apache/commons/lang3/reflect/testbed/Annotated.java
Transmitting file data ......
Committed revision 1612063.
{code}
Thanks for contributing!
> Provide methods to retrieve all fields/methods annotated with a specific type
> -----------------------------------------------------------------------------
>
> Key: LANG-1021
> URL: https://issues.apache.org/jira/browse/LANG-1021
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.reflect.*
> Reporter: Alexander Müller
> Fix For: Review Patch
>
> Attachments: annotatedMethodsAndFields.patch
>
>
> I find myself repeatedly searching for fields (or methods) that are annotated
> with a specified annotation like this (field-only example):
> {code}
> 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);
> }
> }
> {code}
> Commons Lang could provide these methods:
> {code}
> 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);
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)