From bd78d0841775b1a1c91ed4eef1defc62b33e9ed5 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot @Builder
was introduced as experimental feature in lombok v0.12.0.
@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.
By annotating one of the parameters (if annotating a static 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. These 'singular' builders
+ 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:
build()
, the produced collection will be immutable.build()
does not modify any already generated objects, and, if build()
is later called again, another collection with all the elements added since the creation of the builder is generated.build()
does not modify any already generated objects, and, if build()
is later called again, another collection with all the elements added since the creation of the builder is generated.-- cgit