Class GeneratedAnnotations


  • public final class GeneratedAnnotations
    extends java.lang.Object
    Utility methods for writing @Generated annotations.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.util.Optional<javax.lang.model.element.TypeElement> generatedAnnotation​(javax.lang.model.util.Elements elements)
      static java.util.Optional<javax.lang.model.element.TypeElement> generatedAnnotation​(javax.lang.model.util.Elements elements, javax.lang.model.SourceVersion sourceVersion)
      Returns the element corresponding to the @Generated annotation present at the target SourceVersion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generatedAnnotation

        @Deprecated
        public static java.util.Optional<javax.lang.model.element.TypeElement> generatedAnnotation​(javax.lang.model.util.Elements elements)
        Returns the element corresponding to the version of the @Generated annotation present in the compile-time class- or module-path.

        First looks for javax.annotation.processing.Generated, and then javax.annotation.Generated. Returns whichever is in the classpath (or modulepath), or Optional.empty() if neither is.

      • generatedAnnotation

        public static java.util.Optional<javax.lang.model.element.TypeElement> generatedAnnotation​(javax.lang.model.util.Elements elements,
                                                                                                   javax.lang.model.SourceVersion sourceVersion)
        Returns the element corresponding to the @Generated annotation present at the target SourceVersion.

        Returns javax.annotation.processing.Generated for JDK 9 and newer, javax.annotation.Generated for earlier releases, and Optional#empty()} if the annotation is not available.