From 6e2d23fdd7613de9650ffaf00c6e24a6ead0d74b Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Fri, 7 Feb 2020 14:28:46 +0100 Subject: 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 --- src/core/lombok/experimental/SuperBuilder.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/core/lombok/experimental/SuperBuilder.java') 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 ""; } -- cgit