Class GeneratedAnnotationSpecs


  • public final class GeneratedAnnotationSpecs
    extends Object
    Utility methods for writing @Generated annotations using JavaPoet.
    • Method Detail

      • generatedAnnotationSpec

        public static Optional<com.squareup.javapoet.AnnotationSpec> generatedAnnotationSpec​(Elements elements,
                                                                                             SourceVersion sourceVersion,
                                                                                             Class<?> processorClass)
        Returns @Generated("processorClass") for 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.

      • generatedAnnotationSpec

        public static Optional<com.squareup.javapoet.AnnotationSpec> generatedAnnotationSpec​(Elements elements,
                                                                                             SourceVersion sourceVersion,
                                                                                             Class<?> processorClass,
                                                                                             String comments)
        Returns @Generated(value = "processorClass", comments = "comments") for 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.