< prev index next >

src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java

Print this page




  59      * Returns {@code true} if an error was raised in the prior round
  60      * of processing; returns {@code false} otherwise.
  61      *
  62      * @return {@code true} if an error was raised in the prior round
  63      * of processing; returns {@code false} otherwise
  64      */
  65     boolean errorRaised();
  66 
  67     /**
  68      * Returns the root elements for annotation processing generated
  69      * by the prior round.
  70      *
  71      * @return the root elements for annotation processing generated
  72      * by the prior round, or an empty set if there were none
  73      */
  74     Set<? extends Element> getRootElements();
  75 
  76     /**
  77      * Returns the elements annotated with the given annotation type.
  78      * The annotation may appear directly or be inherited.  Only
  79      * package elements and type elements <i>included</i> in this
  80      * round of annotation processing, or declarations of members,
  81      * constructors, parameters, or type parameters declared within
  82      * those, are returned.  Included type elements are {@linkplain
  83      * #getRootElements root types} and any member types nested within
  84      * them.  Elements in a package are not considered included simply
  85      * because a {@code package-info} file for that package was
  86      * created.



  87      *
  88      * @param a  annotation type being requested
  89      * @return the elements annotated with the given annotation type,
  90      * or an empty set if there are none
  91      * @throws IllegalArgumentException if the argument does not
  92      * represent an annotation type
  93      */
  94     Set<? extends Element> getElementsAnnotatedWith(TypeElement a);
  95 
  96     /**
  97      * Returns the elements annotated with one or more of the given
  98      * annotation types.
  99      *
 100      * @apiNote This method may be useful when processing repeating
 101      * annotations by looking for an annotation type and its
 102      * containing annotation type at the same time.
 103      *
 104      * @implSpec The default implementation of this method creates an
 105      * empty result set, iterates over the annotations in the argument
 106      * array calling {@link #getElementsAnnotatedWith(TypeElement)} on


 111      * @param annotations  annotation types being requested
 112      * @return the elements annotated with one or more of the given
 113      * annotation types, or an empty set if there are none
 114      * @throws IllegalArgumentException if the any elements of the
 115      * argument set do not represent an annotation type
 116      * @jls 9.6.3 Repeatable Annotation Types
 117      * @since 9
 118      */
 119     default Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annotations){
 120         // Use LinkedHashSet rather than HashSet for predictability
 121         Set<Element> result = new LinkedHashSet<>();
 122         for (TypeElement annotation : annotations) {
 123             result.addAll(getElementsAnnotatedWith(annotation));
 124         }
 125         return Collections.unmodifiableSet(result);
 126     }
 127 
 128     /**
 129      * Returns the elements annotated with the given annotation type.
 130      * The annotation may appear directly or be inherited.  Only
 131      * package elements and type elements <i>included</i> in this
 132      * round of annotation processing, or declarations of members,
 133      * constructors, parameters, or type parameters declared within
 134      * those, are returned.  Included type elements are {@linkplain
 135      * #getRootElements root types} and any member types nested within
 136      * them.  Elements in a package are not considered included simply
 137      * because a {@code package-info} file for that package was
 138      * created.



 139      *
 140      * @param a  annotation type being requested
 141      * @return the elements annotated with the given annotation type,
 142      * or an empty set if there are none
 143      * @throws IllegalArgumentException if the argument does not
 144      * represent an annotation type
 145      */
 146     Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);
 147 
 148     /**
 149      * Returns the elements annotated with one or more of the given
 150      * annotation types.
 151      *
 152      * @apiNote This method may be useful when processing repeating
 153      * annotations by looking for an annotation type and its
 154      * containing annotation type at the same time.
 155      *
 156      * @implSpec The default implementation of this method creates an
 157      * empty result set, iterates over the annotations in the argument
 158      * set calling {@link #getElementsAnnotatedWith(Class)} on




  59      * Returns {@code true} if an error was raised in the prior round
  60      * of processing; returns {@code false} otherwise.
  61      *
  62      * @return {@code true} if an error was raised in the prior round
  63      * of processing; returns {@code false} otherwise
  64      */
  65     boolean errorRaised();
  66 
  67     /**
  68      * Returns the root elements for annotation processing generated
  69      * by the prior round.
  70      *
  71      * @return the root elements for annotation processing generated
  72      * by the prior round, or an empty set if there were none
  73      */
  74     Set<? extends Element> getRootElements();
  75 
  76     /**
  77      * Returns the elements annotated with the given annotation type.
  78      * The annotation may appear directly or be inherited.  Only
  79      * package elements, module elements, and type elements <i>included</i> in this
  80      * round of annotation processing, or declarations of members,
  81      * constructors, parameters, or type parameters declared within
  82      * those, are returned.  Included type elements are {@linkplain
  83      * #getRootElements root types} and any member types nested within
  84      * them.  Elements of a package are not considered included simply
  85      * because a {@code package-info} file for that package was
  86      * created.
  87      * Likewise, elements of a module are not considered included
  88      * simply because a {@code module-info} file for that module was
  89      * created
  90      *
  91      * @param a  annotation type being requested
  92      * @return the elements annotated with the given annotation type,
  93      * or an empty set if there are none
  94      * @throws IllegalArgumentException if the argument does not
  95      * represent an annotation type
  96      */
  97     Set<? extends Element> getElementsAnnotatedWith(TypeElement a);
  98 
  99     /**
 100      * Returns the elements annotated with one or more of the given
 101      * annotation types.
 102      *
 103      * @apiNote This method may be useful when processing repeating
 104      * annotations by looking for an annotation type and its
 105      * containing annotation type at the same time.
 106      *
 107      * @implSpec The default implementation of this method creates an
 108      * empty result set, iterates over the annotations in the argument
 109      * array calling {@link #getElementsAnnotatedWith(TypeElement)} on


 114      * @param annotations  annotation types being requested
 115      * @return the elements annotated with one or more of the given
 116      * annotation types, or an empty set if there are none
 117      * @throws IllegalArgumentException if the any elements of the
 118      * argument set do not represent an annotation type
 119      * @jls 9.6.3 Repeatable Annotation Types
 120      * @since 9
 121      */
 122     default Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annotations){
 123         // Use LinkedHashSet rather than HashSet for predictability
 124         Set<Element> result = new LinkedHashSet<>();
 125         for (TypeElement annotation : annotations) {
 126             result.addAll(getElementsAnnotatedWith(annotation));
 127         }
 128         return Collections.unmodifiableSet(result);
 129     }
 130 
 131     /**
 132      * Returns the elements annotated with the given annotation type.
 133      * The annotation may appear directly or be inherited.  Only
 134      * package elements, module elements, and type elements <i>included</i> in this
 135      * round of annotation processing, or declarations of members,
 136      * constructors, parameters, or type parameters declared within
 137      * those, are returned.  Included type elements are {@linkplain
 138      * #getRootElements root types} and any member types nested within
 139      * them.  Elements in a package are not considered included simply
 140      * because a {@code package-info} file for that package was
 141      * created.
 142      * Likewise, elements of a module are not considered included
 143      * simply because a {@code module-info} file for that module was
 144      * created
 145      *
 146      * @param a  annotation type being requested
 147      * @return the elements annotated with the given annotation type,
 148      * or an empty set if there are none
 149      * @throws IllegalArgumentException if the argument does not
 150      * represent an annotation type
 151      */
 152     Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);
 153 
 154     /**
 155      * Returns the elements annotated with one or more of the given
 156      * annotation types.
 157      *
 158      * @apiNote This method may be useful when processing repeating
 159      * annotations by looking for an annotation type and its
 160      * containing annotation type at the same time.
 161      *
 162      * @implSpec The default implementation of this method creates an
 163      * empty result set, iterates over the annotations in the argument
 164      * set calling {@link #getElementsAnnotatedWith(Class)} on


< prev index next >