diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-03-25 23:11:48 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-03-25 23:11:48 +0100 |
commit | 228e99fe5203e92c7297325fec69a82abc1a4bd7 (patch) | |
tree | d3176a94f672a58f9c9927d812d048323080f363 /website | |
parent | 535e20972c56e65b598df0d0849a25daa7a69e8d (diff) | |
download | lombok-228e99fe5203e92c7297325fec69a82abc1a4bd7.tar.gz lombok-228e99fe5203e92c7297325fec69a82abc1a4bd7.tar.bz2 lombok-228e99fe5203e92c7297325fec69a82abc1a4bd7.zip |
[fixes #2046] you can now suppress the builder() method, useful if you only want toBuilder(). Also suppresses the warnings about any missing Builder.Default annotations.
Diffstat (limited to 'website')
-rw-r--r-- | website/templates/features/Builder.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/website/templates/features/Builder.html b/website/templates/features/Builder.html index 082b97ed..0818f9d2 100644 --- a/website/templates/features/Builder.html +++ b/website/templates/features/Builder.html @@ -10,6 +10,8 @@ <code>@Builder</code> with <code>@Singular</code> adds a clear method since lombok v1.16.8. </p><p> <code>@Builder.Default</code> functionality was added in lombok v1.16.16. + </p><p> + <code>@Builder(builderMethodName = "")</code> is legal (and will suppress generation of the builder method) starting with lombok v1.18.8. </p> </@f.history> @@ -184,6 +186,13 @@ public class JacksonExample { </p><p> 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 <a href="/features/GetterSetter">Getter/Setter</a> documentation's small print for more information. </p><p> + You can suppress the generation of the <code>builder()</code> method, for example because you <em>just</em> want the <code>toBuilder()</code> functionality, by using: + <code>@Builder(builderMethodName = "")</code>. Any warnings about missing <code>@Builder.Default</code> annotations will disappear when you do this, as such warnings + are not relevant when only using <code>toBuilder()</code> to make builder instances. + </p><p> + You can use <code>@Builder</code> for copy constructors: <code>foo.toBuilder().build()</code> makes a shallow clone. Consider suppressing the generating of the + <code>builder</code> method if you just want this functionality, by using: <code>@Builder(toBuilder = true, builderMethodName = "")</code>. + </p><p> Due to a peculiar way javac processes static imports, trying to do a non-star static import of the static <code>builder()</code> method won't work. Either use a star static import: `import static TypeThatHasABuilder.*;` or don't statically import the <code>builder</code> method. </p> </@f.smallPrint> |