From 228e99fe5203e92c7297325fec69a82abc1a4bd7 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot @Builder
with @Singular
adds a clear method since lombok v1.16.8.
@Builder.Default
functionality was added in lombok v1.16.16.
+
+ @Builder(builderMethodName = "")
is legal (and will suppress generation of the builder method) starting with lombok v1.18.8.
@Builder.Default
field is removed and stored in a static method, in order to guarantee that this initializer won't be executed at all if a value is specified in the build. This does mean the initializer cannot refer to this
, super
or any non-static member. If lombok generates a constructor for you, it'll also initialize this field with the initializer.
Various well known annotations about nullity cause null checks to be inserted and will be copied to parameter of the builder's 'setter' method. See Getter/Setter documentation's small print for more information. +
+ You can suppress the generation of the builder()
method, for example because you just want the toBuilder()
functionality, by using:
+ @Builder(builderMethodName = "")
. Any warnings about missing @Builder.Default
annotations will disappear when you do this, as such warnings
+ are not relevant when only using toBuilder()
to make builder instances.
+
+ You can use @Builder
for copy constructors: foo.toBuilder().build()
makes a shallow clone. Consider suppressing the generating of the
+ builder
method if you just want this functionality, by using: @Builder(toBuilder = true, builderMethodName = "")
.
Due to a peculiar way javac processes static imports, trying to do a non-star static import of the static builder()
method won't work. Either use a star static import: `import static TypeThatHasABuilder.*;` or don't statically import the builder
method.