Package com.google.auto.value
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:
- AutoValue and its nested annotations;
- any annotation appearing in the
exclude()
field; - 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.When the type of an
@AutoValue
property method has annotations, those are part of the type, so they are always copied to the implementation of the method.@CopyAnnotations
has no effect here. For example, suppose@Confidential
is aTYPE_USE
annotation:@AutoValue abstract class Person { static Person create(@Confidential String name, int id) { return new AutoValue_Person(name, id); } abstract @Confidential String name(); abstract int id(); }
Then the implementation of thename()
method will also have return type@Confidential String
.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<? extends java.lang.annotation.Annotation>[]
exclude
-