Annotation Interface Accessors


@GwtCompatible @Target({FIELD,TYPE}) @Documented public @interface Accessors
Creates getters and setters for annotated fields or for all fields in an annotated class.

Annotated on a field

  • Creates a getter for that field if none exists. For primitive boolean properties, the "is"-prefix is used.
  • Creates a setter for that field if it is not final and no setter exists
  • By default the accessors are public
  • If the AccessorType[] argument is given, only the listed accessors with the specified visibility will be generated
  • By default the accessors will be deprecated if the field is annotated as such. This can be changed by explicitly providing deprecationPolicy

Annotated on a class

  • Creates accessors for all non-static fields of that class as specified above
  • Creates a constructor taking all final fields of the class if no constructor exists yet. If there already is a constructor and you want the default one on top of that, you can use the FinalFieldsConstructor annotation.

Field-level annotations have precedence over a class-level annotation. Accessors can be suppressed completely by using AccessorType.NONE. This annotation can also be used to fine-tune the getters generated by Data.
Since:
2.7
  • Element Details

    • value

      AccessorType[] value
      Describes the access modifiers for generated accessors. Valid combinations include at most one type for getters and one for setters. Accessors may be suppressed by passing AccessorType.NONE.
      Default:
      {PUBLIC_GETTER, PUBLIC_SETTER}
    • deprecationPolicy

      @Beta AccessorsDeprecationPolicy deprecationPolicy
      Describes when @Deprecated will be added to generated accessors.
      If it is not wanted or needed, pass AccessorsDeprecationPolicy.NEVER to prevent the annotation from being added.
      Since:
      2.23
      Default:
      SAME_AS_FIELD