From 72fd50b9f1db1ab6bfc1753ba6a1e686a2f0f22c Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 8 May 2017 21:11:15 +0200 Subject: moved an update to the website text about the jdk8 onX support to the new website templates. --- website2/templates/features/Builder.html | 15 +++++++++++++-- website2/templates/features/constructor.html | 2 +- website2/templates/features/experimental/onX.html | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'website2') diff --git a/website2/templates/features/Builder.html b/website2/templates/features/Builder.html index 238fada3..a6b8d18f 100644 --- a/website2/templates/features/Builder.html +++ b/website2/templates/features/Builder.html @@ -8,6 +8,8 @@ @Builder gained @Singular support and was promoted to the main lombok package since lombok v1.16.0.

@Builder with @Singular adds a clear method since lombok v1.16.8. +

+ @Builder.Default functionality was added in lombok v1.16.16.

@@ -66,10 +68,19 @@ @Builder(builderClassName = "HelloWorldBuilder", buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true)

- + + <@f.featureSection> +

@Builder.Default

+ +

+ If a certain field/parameter is never set during a build session, then it always gets 0 / null / false. If you've put @Builder on a class (and not a method or constructor) you can instead specify the default directly on the field, and annotate the field with @Builder.Default:
+ @Builder.Default private final long created = System.currentTimeMillis(); +

+ + <@f.featureSection>

@Singular

- +

By annotating one of the parameters (if annotating a method or constructor with @Builder) or fields (if annotating a class with @Builder) with the @Singular annotation, lombok will treat that builder node as a collection, and it generates 2 'adder' methods instead of a 'setter' method. One which adds a single element to the collection, and one which adds all elements of another collection to the collection. No setter to just set the collection (replacing whatever was already added) will be generated. A 'clear' method is also generated. These 'singular' builders are very complicated in order to guarantee the following properties: