Annotation Type AutoValue.CopyAnnotations


  • @Retention(CLASS)
    @Target({TYPE,METHOD})
    public static @interface AutoValue.CopyAnnotations
    Specifies that AutoValue should copy any annotations from the annotated element to the generated class. This annotation supports classes and methods.

    The following annotations are excluded:

    1. AutoValue and its nested annotations;
    2. any annotation appearing in the exclude() field;
    3. any class annotation which is itself annotated with the Inherited meta-annotation.

    For historical reasons, annotations are always copied from an @AutoValue property method to its implementation, unless @CopyAnnotations is present and explicitly excludes that annotation. But annotations are not copied from the @AutoValue class itself to its implementation unless @CopyAnnotations is present.

    If you want to copy annotations from your @AutoValue-annotated class's methods to the generated fields in the AutoValue_... implementation, annotate your method with @AutoValue.CopyAnnotations. For example, if Example.java is:

    {@code
    Author:
    Carmi Grushko
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      Class<? extends Annotation>[] exclude