Uploaded image for project: 'CCC Migration Project'
  1. CCC Migration Project
  2. CCC-8032230

Enhance javax.a.p.RoundEnvironment after repeating annotations

    XMLWordPrintable

Details

    • source
    • low
    • Adding new default methods to an interface.
    • Java API
    • SE

    Description

      Summary

      Add methods to RoundEnvironment to allow querying on more than one annotation.

      Problem

      Especially after repeating annotations, during annotation processing it would be helpful to be able to look for more than one annotation at a time.

      Solution

      Add a pair of methods that allow multiple annotations to be looked for.

      Specification

      /**
      +     * Returns the elements annotated with one or more of the given
      +     * annotation types.
      +     *
      +     * @apiNote This method may be useful when processing repeating
      +     * annotations by looking for an annotation type and its
      +     * containing annotation type at the same time.
      +     *
      +     * @implSpec The default implementation of this method creates an
      +     * empty result set, iterates over the annotations in the argument
      +     * set calling {@link #getElementsAnnotatedWith(TypeElement)} on
      +     * each annotation and adding those results to the result
      +     * set. Finally, the contents of the result set are returned as an
      +     * unmodifiable set.
      +     *
      +     * @param annotations  annotation types being requested
      +     * @return the elements annotated with one or more of the given
      +     * annotation types, or an empty set if there are none
      +     * @throws IllegalArgumentException if the any elements of the
      +     * argument set do not represent an annotation type
      +     * @since 9
      +     */
      +    default Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annotations)
      
      +    /**
      +     * Returns the elements annotated with one or more of the given
      +     * annotation types.
      +     *
      +     * @apiNote This method may be useful when processing repeating
      +     * annotations by looking for an annotation type and its
      +     * containing annotation type at the same time.
      +     *
      +     * @implSpec The default implementation of this method creates an
      +     * empty result set, iterates over the annotations in the argument
      +     * set calling {@link #getElementsAnnotatedWith(Class)} on
      +     * each annotation and adding those results to the result
      +     * set. Finally, the contents of the result set are returned as an
      +     * unmodifiable set.
      +     *
      +     * @param annotations  annotation types being requested
      +     * @return the elements annotated with one or more of the given
      +     * annotation types, or an empty set if there are none
      +     * @throws IllegalArgumentException if the any elements of the
      +     * argument set do not represent an annotation type
      +     * @since 9
      +     */
      +    default Set<? extends Element> getElementsAnnotatedWithAny(Set<Class<? extends Annotation>> annotations)

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              darcy Joe Darcy
              Alex Buckley, Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: