From 5f198d71c684c6a2f1eec9ae6026cca5f4fd7c30 Mon Sep 17 00:00:00 2001 From: Caleb Brinkman Date: Wed, 10 Jul 2019 15:03:09 -0500 Subject: Add setterPrefix to Builder annotation --- src/core/lombok/Builder.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core/lombok/Builder.java') diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index dfa5ecb5..d7fe42a1 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -153,6 +153,16 @@ public @interface Builder { * @return The builder class will be generated with this access modifier. */ AccessLevel access() default lombok.AccessLevel.PUBLIC; + + /** + * Prefix to prepend to set methods in the generated builder class. By default, generated methods to not include a + * prefix. If this value populated, the first letter of the generated method name will be capitalized. + * + * For example, a method normally generated as {@code someField(String someField)} would instead be generated as {@code withSomeField(String someField)} + * + * @return The prefix to prepend to generated method names. + */ + String setterPrefix() default ""; /** * Put on a field (in case of {@code @Builder} on a type) or a parameter (for {@code @Builder} on a constructor or static method) to -- cgit From 2baefe08cedebc9ef8c468b7de353e66b23eded1 Mon Sep 17 00:00:00 2001 From: Caleb Brinkman Date: Wed, 11 Sep 2019 09:20:39 -0500 Subject: Explicitly recommend against prefixes --- src/core/lombok/Builder.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core/lombok/Builder.java') diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index d7fe42a1..fcbe1a09 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -160,6 +160,9 @@ public @interface Builder { * * For example, a method normally generated as {@code someField(String someField)} would instead be generated as {@code withSomeField(String someField)} * + * 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. + * * @return The prefix to prepend to generated method names. */ String setterPrefix() default ""; -- cgit