Annotation Type Accessors


@Target({TYPE,FIELD}) @Retention(SOURCE) public @interface Accessors
A container for settings for the generation of getters, setters and "with"-ers.

Complete documentation is found at the project lombok features page for @Accessors.

Using this annotation does nothing by itself; an annotation that makes lombok generate getters, setters, or "with"-ers such as Setter or Data is also required.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    If true, setters return this instead of void.
    boolean
    If true, accessors will be named after the field and not include a get or set prefix.
    boolean
    If true, generated accessors will be marked final.
    If present, only fields with any of the stated prefixes are given the getter/setter treatment.
  • Element Details

    • fluent

      boolean fluent
      If true, accessors will be named after the field and not include a get or set prefix. If true and chain is omitted, chain defaults to true.
      NB: This setting has no effect on @With; they always get a "with" prefix.
      default: false
      Returns:
      Whether or not to make fluent methods (named fieldName(), not for example setFieldName).
      Default:
      false
    • chain

      boolean chain
      If true, setters return this instead of void. default: false, unless fluent=true, then default: true
      Returns:
      Whether or not setters should return themselves (chaining) or void (no chaining).
      Default:
      false
    • makeFinal

      boolean makeFinal
      If true, generated accessors will be marked final. default: false
      Returns:
      Whether or not accessors should be marked final.
      Default:
      false
    • prefix

      String[] prefix
      If present, only fields with any of the stated prefixes are given the getter/setter treatment. Note that a prefix only counts if the next character is NOT a lowercase character or the last letter of the prefix is not a letter (for instance an underscore). If multiple fields all turn into the same name when the prefix is stripped, an error will be generated.
      Returns:
      If you are in the habit of prefixing your fields (for example, you name them fFieldName, specify such prefixes here).
      Default:
      {}