From ceeabe510360b93613d52f1d0c083fdf0149135d Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 21 Mar 2012 05:25:56 +0100 Subject: Documentation for new @Accessors feature as well as the API (the annotation in experimental package). --- website/features/experimental/Accessors.html | 103 +++++++++++++++++++++++++++ website/features/experimental/index.html | 45 ++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 website/features/experimental/Accessors.html create mode 100644 website/features/experimental/index.html (limited to 'website/features/experimental') diff --git a/website/features/experimental/Accessors.html b/website/features/experimental/Accessors.html new file mode 100644 index 00000000..bbcd80bb --- /dev/null +++ b/website/features/experimental/Accessors.html @@ -0,0 +1,103 @@ + + + + + + + + EXPERIMENTAL - @Accessors +
+
+
+ +

@Accessors

+ +
+

Since

+

+ @Accessors was introduced as experimental feature in lombok v0.10.10. +

+
+
+

Experimental

+

+ Experimental because: +

    +
  • We may want to roll these features into a more complete property support concept.
  • +
  • New feature - community feedback requested.
  • +
+ Current status: positive - Currently we feel this feature may move out of experimental status with no or minor changes soon. +
+
+

Overview

+

+ The @Accessors annotation is used to configure how lombok generates and looks for getters and setters. +

+ By default, lombok follows the bean specification for getters and setters: The getter for a field named pepper + is getPepper for example. However, some might like to break with the bean specification in order to end up with + nicer looking APIs. @Accessors lets you do this. +

+ Some programmers like to use a prefix for their fields, i.e. they write fPepper instead of pepper. + We strongly discourage doing this, as you can't unit test the validity of your prefixes, and refactor scripts may turn fields + into local variables or method names. Furthermore, your tools (such as your editor) can take care of rendering the identifier in a + certain way if you want this information to be instantly visible. Nevertheless, you can list the prefixes that your project uses via + @Accessors as well. +

+ @Accessors therefore has 3 options:

    +
  • fluent - A boolean. If true, the getter for pepper is just pepper(), and the + setter is pepper(T newValue). Furthermore, unless specified, chain defaults to true.
    + Default: false.
  • +
  • chain - A boolean. If true, generated setters return this instead of void.
    + Default: false, unless fluent=true, then Default: true.
  • +
  • prefix - A list of strings. If present, fields must be prefixed with any of these prefixes. Each field name is + compared to each prefix in the list in turn, and if a match is found, the prefix is stripped out to create the base name for + the field. It is legal to include an empty string in the list, which will always match. For characters which are letters, the + character following the prefix must not be a lowercase letter, i.e. pepper is not a match even to prefix p, + but pEpper would be (and would mean the base name of this field is epper).
  • +

    + The @Accessors annotation is legal on types and fields; the annotation that applies is the one on the field if present, + otherwise the one on the class. When a @Accessors annotation on a field is present, any @Accessors annotation + also present on that field's type is ignored. +

    +
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+

+ The nearest @Accessors annotation is also used for the various methods in lombok that look for getters, such as + @EqualsAndHashCode. +

+ If a prefix list is provided and a field does not start with one of them, that field is skipped entirely by lombok, and + a warning will be generated. +

+
+
+ +
+
+
+ + + diff --git a/website/features/experimental/index.html b/website/features/experimental/index.html new file mode 100644 index 00000000..e4e90c41 --- /dev/null +++ b/website/features/experimental/index.html @@ -0,0 +1,45 @@ + + + + + + + + Lombok feature overview +
+
+
+ +

Lombok experimental features

+
+ Experimental features are available in your normal lombok installation, but are not as robustly supported as lombok's main features. + In particular, experimental features:
    +
  • Are not tested as well as the core features.
  • +
  • Do not get bugs fixed as quickly as core features.
  • +
  • May have APIs that will change, possibly drastically if we find a different, better way to solve the same problem.
  • +
  • May disappear entirely if the feature is too difficult to support or does bust enough boilerplate.
  • +
+ Features that receive positive community feedback and which seem to produce clean, flexible code will eventually become accepted + as a core feature and move out of the experimental package. +
+
@Accessors
+
A more fluent API for getters and setters.
+
+
+ +
+
+
+ + + -- cgit