aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/experimental/SuperBuilder.java
diff options
context:
space:
mode:
authorJan Rieke <it@janrieke.de>2020-02-07 14:28:46 +0100
committerJan Rieke <it@janrieke.de>2020-02-08 16:09:56 +0100
commit6e2d23fdd7613de9650ffaf00c6e24a6ead0d74b (patch)
treea68700c831edbf056fa1f8773e7ef9c941eab982 /src/core/lombok/experimental/SuperBuilder.java
parentcf4e59662a8aac42beee50d2fc28487b7aaf9ea6 (diff)
downloadlombok-6e2d23fdd7613de9650ffaf00c6e24a6ead0d74b.tar.gz
lombok-6e2d23fdd7613de9650ffaf00c6e24a6ead0d74b.tar.bz2
lombok-6e2d23fdd7613de9650ffaf00c6e24a6ead0d74b.zip
setter prefixes for SuperBuilder
setter prefixes for SuperBuilder [javac] better javadoc for the SuperBuilder setterPrefix value setter prefixes for SuperBuilder [ecj] add test for SuperBuilder setter method customization fix setter method customization with setterPrefix
Diffstat (limited to 'src/core/lombok/experimental/SuperBuilder.java')
-rw-r--r--src/core/lombok/experimental/SuperBuilder.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/lombok/experimental/SuperBuilder.java b/src/core/lombok/experimental/SuperBuilder.java
index aef76a46..0733a616 100644
--- a/src/core/lombok/experimental/SuperBuilder.java
+++ b/src/core/lombok/experimental/SuperBuilder.java
@@ -62,4 +62,23 @@ public @interface SuperBuilder {
* @return Whether to generate a {@code toBuilder()} method.
*/
boolean toBuilder() default false;
+
+ /**
+ * Prefix to prepend to 'set' methods in the generated builder class. By default, generated methods do not include a prefix.
+ *
+ * For example, a method normally generated as {@code someField(String someField)} would instead be
+ * generated as {@code withSomeField(String someField)} if using {@code @SuperBuilder(setterPrefix = "with")}.
+ *
+ * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally
+ * suggests immutable data structures, and builders by definition are mutable objects.
+ *
+ * For {@code @Singular} fields, the generated methods are called {@code withName}, {@code withNames}, and {@code clearNames}, instead of
+ * the default {@code name}, {@code names}, and {@code clearNames}.
+ *
+ * This prefix only applies to the 'set' methods for the fields of the annotated class.
+ * For consistency reasons, you should use the same prefix on all superclasses and subclasses that use {@code @SuperBuilder}.
+ *
+ * @return The prefix to prepend to generated method names.
+ */
+ String setterPrefix() default "";
}