You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (JIRA)" <ji...@apache.org> on 2014/07/07 20:00:38 UTC

[jira] [Commented] (LANG-1021) Provide methods to retrieve all fields/methods annotated with a specific type

    [ https://issues.apache.org/jira/browse/LANG-1021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14053939#comment-14053939 ] 

Benedikt Ritter commented on LANG-1021:
---------------------------------------

Well, I feel like those should be deprecated for removal in 4.0...

Another think I'm not sure about is, whether this belongs to {{AnnotationUtils}} or if we can put it into {{Field/MethodUtils}}. If there is a {{getAllFields()}} method in FieldUtils, why should I look at {{AnnotationUtils}} if I want to have the subset of all fields which are annotated with an annotation?

> 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
>
>
> 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)