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: