aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java34
-rw-r--r--src/core/lombok/experimental/SuperBuilder.java19
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java37
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderCustomized.java9
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java50
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java201
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderCustomized.java8
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java45
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java168
-rw-r--r--test/transform/resource/before/SuperBuilderCustomized.java4
-rw-r--r--test/transform/resource/before/SuperBuilderCustomizedWithSetterPrefix.java18
-rw-r--r--test/transform/resource/before/SuperBuilderWithSetterPrefix.java32
12 files changed, 582 insertions, 43 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 12fa9b2c..82af39fa 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -179,7 +179,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = copyAnnotations(fd, copyableAnnotations);
bfd.type = fd.type;
- bfd.singularData = getSingularData(fieldNode, ast);
+ bfd.singularData = getSingularData(fieldNode, ast, superbuilderAnnotation.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -335,7 +335,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// Generate $fillValuesFrom() method in the abstract builder.
injectMethod(builderType, generateFillValuesMethod(tdParent, superclassBuilderClass != null, builderGenericName, classGenericName, builderClassName, typeParams));
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
- injectMethod(builderType, generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, ast));
+ injectMethod(builderType, generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, ast, superbuilderAnnotation.setterPrefix()));
}
// Generate abstract self() and build() methods in the abstract builder.
@@ -344,7 +344,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// Create the setter methods in the abstract builder.
for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName);
+ generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName, superbuilderAnnotation.setterPrefix());
}
// Create the toString() method for the abstract builder.
@@ -701,8 +701,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* b.field(instance.field);
* }
* </pre>
+ * @param setterPrefix the prefix for setter methods
*/
- private MethodDeclaration generateStaticFillValuesMethod(EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, java.util.List<BuilderFieldData> builderFields, ASTNode source) {
+ private MethodDeclaration generateStaticFillValuesMethod(EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, java.util.List<BuilderFieldData> builderFields, ASTNode source, String setterPrefix) {
MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
out.selector = FILL_VALUES_STATIC_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
@@ -731,7 +732,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// Call the builder's setter methods to fill the values from the instance.
for (BuilderFieldData bfd : builderFields) {
- MessageSend exec = createSetterCallWithInstanceValue(bfd, tdParent, source);
+ MessageSend exec = createSetterCallWithInstanceValue(bfd, tdParent, source, setterPrefix);
body.add(exec);
}
@@ -740,8 +741,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
return out;
}
- private MessageSend createSetterCallWithInstanceValue(BuilderFieldData bfd, EclipseNode type, ASTNode source) {
- char[] setterName = bfd.name;
+ private MessageSend createSetterCallWithInstanceValue(BuilderFieldData bfd, EclipseNode type, ASTNode source, String setterPrefix) {
+ char[] setterName = HandlerUtil.buildAccessorName(setterPrefix, String.valueOf(bfd.name)).toCharArray();
MessageSend ms = new MessageSend();
Expression[] tgt = new Expression[bfd.singularData == null ? 1 : 2];
@@ -919,7 +920,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
}
- private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, final String builderGenericName) {
+ private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, final String builderGenericName, String setterPrefix) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() {
@@ -938,29 +939,27 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
};
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, true, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations, bfd.originalFieldNode);
+ generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations, bfd.originalFieldNode, setterPrefix);
} else {
bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
- private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, boolean fluent, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam, EclipseNode originalFieldNode) {
+ private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam, EclipseNode originalFieldNode, String setterPrefix) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
ASTNode source = sourceNode.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY_METHODS;
int len = existing.length;
- FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
- char[] name = fd.name;
+
+ String setterName = HandlerUtil.buildAccessorName(setterPrefix, new String(paramName));
for (int i = 0; i < len; i++) {
if (!(existing[i] instanceof MethodDeclaration)) continue;
char[] existingName = existing[i].selector;
- if (Arrays.equals(name, existingName) && !isTolerate(fieldNode, existing[i])) return;
+ if (Arrays.equals(setterName.toCharArray(), existingName) && !isTolerate(fieldNode, existing[i])) return;
}
- String setterName = fluent ? new String(paramName) : HandlerUtil.buildAccessorName("set", new String(paramName));
-
List<Annotation> methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode));
if (cfv.generateReturnsReceiver()) {
methodAnnsList = new ArrayList<Annotation>(methodAnnsList);
@@ -997,8 +996,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* or parameter), or null if there's no {@code @Singular} annotation on it.
*
* @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation.
+ * @param setterPrefix the prefix for setter methods
*/
- private SingularData getSingularData(EclipseNode node, ASTNode source) {
+ private SingularData getSingularData(EclipseNode node, ASTNode source, String setterPrefix) {
for (EclipseNode child : node.down()) {
if (!annotationTypeMatches(Singular.class, child)) continue;
@@ -1047,7 +1047,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
return null;
}
- return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.<TypeReference>emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source, singularInstance.ignoreNullCollections());
+ return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.<TypeReference>emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source, singularInstance.ignoreNullCollections(), setterPrefix.toCharArray());
}
return null;
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 "";
}
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 650b0964..c9df4811 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -117,7 +117,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
boolean toBuilder = superbuilderAnnotation.toBuilder();
-
+
JavacNode tdParent = annotationNode.up();
java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
@@ -148,7 +148,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = findCopyableAnnotations(fieldNode);
bfd.type = fd.vartype;
- bfd.singularData = getSingularData(fieldNode);
+ bfd.singularData = getSingularData(fieldNode, superbuilderAnnotation.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -281,7 +281,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
recursiveSetGeneratedBy(fvm, ast, annotationNode.getContext());
injectMethod(builderType, fvm);
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
- JCMethodDecl sfvm = generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields);
+ JCMethodDecl sfvm = generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, superbuilderAnnotation.setterPrefix());
recursiveSetGeneratedBy(sfvm, ast, annotationNode.getContext());
injectMethod(builderType, sfvm);
}
@@ -296,7 +296,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Create the setter methods in the abstract builder.
for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName);
+ generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName, superbuilderAnnotation.setterPrefix());
}
// Create the toString() method for the abstract builder.
@@ -671,8 +671,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* b.field(instance.field);
* }
* </pre>
+ * @param setterPrefix the prefix for setter methods
*/
- private JCMethodDecl generateStaticFillValuesMethod(JavacNode type, String builderClassname, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields) {
+ private JCMethodDecl generateStaticFillValuesMethod(JavacNode type, String builderClassname, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, String setterPrefix) {
JavacTreeMaker maker = type.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
JCModifiers modifiers = maker.Modifiers(Flags.PRIVATE | Flags.STATIC, annotations);
@@ -697,7 +698,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Call the builder's setter methods to fill the values from the instance.
for (BuilderFieldData bfd : builderFields) {
- JCExpressionStatement exec = createSetterCallWithInstanceValue(bfd, type, maker);
+ JCExpressionStatement exec = createSetterCallWithInstanceValue(bfd, type, maker, setterPrefix);
body.append(exec);
}
@@ -706,7 +707,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return maker.MethodDef(modifiers, name, returnType, copyTypeParams(type, typeParams), List.of(paramInstance, paramBuilder), List.<JCExpression>nil(), bodyBlock, null);
}
- private JCExpressionStatement createSetterCallWithInstanceValue(BuilderFieldData bfd, JavacNode type, JavacTreeMaker maker) {
+ private JCExpressionStatement createSetterCallWithInstanceValue(BuilderFieldData bfd, JavacNode type, JavacTreeMaker maker, String setterPrefix) {
JCExpression[] tgt = new JCExpression[bfd.singularData == null ? 1 : 2];
if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) {
for (int i = 0; i < tgt.length; i++) {
@@ -736,7 +737,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JCExpression emptyCollection = maker.Apply(List.<JCExpression>nil(), chainDots(type, emptyMaker.split("\\.")), List.<JCExpression>nil());
arg = maker.Conditional(eqNull, emptyCollection, tgt[1]);
}
- JCMethodInvocation apply = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(type.toName(BUILDER_VARIABLE_NAME)), bfd.name), List.of(arg));
+
+ String setterName = HandlerUtil.buildAccessorName(setterPrefix, bfd.name.toString());
+ JCMethodInvocation apply = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(type.toName(BUILDER_VARIABLE_NAME)), type.toName(setterName)), List.of(arg));
JCExpressionStatement exec = maker.Exec(apply);
return exec;
}
@@ -872,7 +875,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
}
- private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, final JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, final String builderGenericName) {
+ private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, final JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, final String builderGenericName, String setterPrefix) {
boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode);
final JavacTreeMaker maker = builderType.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
@@ -884,24 +887,23 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}};
if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, true, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode);
+ generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode, setterPrefix);
} else {
fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
- private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode) {
- Name fieldName = ((JCVariableDecl) fieldNode.get()).name;
+ private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, String setterPrefix) {
+ String setterName = HandlerUtil.buildAccessorName(setterPrefix, paramName.toString());
+ Name setterName_ = builderType.toName(setterName);
for (JavacNode child : builderType.down()) {
if (child.getKind() != Kind.METHOD) continue;
JCMethodDecl methodDecl = (JCMethodDecl) child.get();
Name existingName = methodDecl.name;
- if (existingName.equals(fieldName) && !isTolerate(fieldNode, methodDecl)) return;
+ if (existingName.equals(setterName_) && !isTolerate(fieldNode, methodDecl)) return;
}
- String setterName = fluent ? paramName.toString() : HandlerUtil.buildAccessorName("set", paramName.toString());
-
JavacTreeMaker maker = fieldNode.getTreeMaker();
List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
@@ -940,8 +942,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* or parameter), or null if there's no {@code @Singular} annotation on it.
*
* @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation.
+ * @param setterPrefix the prefix for setter methods
*/
- private SingularData getSingularData(JavacNode node) {
+ private SingularData getSingularData(JavacNode node, String setterPrefix) {
for (JavacNode child : node.down()) {
if (!annotationTypeMatches(Singular.class, child)) continue;
Name pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((JCVariableDecl) node.get()).name;
@@ -982,7 +985,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return null;
}
- return new SingularData(child, singularName, pluralName, typeArgs, targetFqn, singularizer, singularInstance.ignoreNullCollections());
+ return new SingularData(child, singularName, pluralName, typeArgs, targetFqn, singularizer, singularInstance.ignoreNullCollections(), setterPrefix);
}
return null;
diff --git a/test/transform/resource/after-delombok/SuperBuilderCustomized.java b/test/transform/resource/after-delombok/SuperBuilderCustomized.java
index e8f95407..bffa72fa 100644
--- a/test/transform/resource/after-delombok/SuperBuilderCustomized.java
+++ b/test/transform/resource/after-delombok/SuperBuilderCustomized.java
@@ -8,15 +8,14 @@ public class SuperBuilderCustomized {
field1 = 0;
return self();
}
+ public B field1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
@java.lang.SuppressWarnings("all")
protected abstract B self();
@java.lang.SuppressWarnings("all")
public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
diff --git a/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java b/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java
new file mode 100644
index 00000000..8cc5dfe0
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java
@@ -0,0 +1,50 @@
+import java.util.List;
+public class SuperBuilderCustomizedWithSetterPrefix {
+ public static class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ public B setField1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ")";
+ }
+ }
+ int field1;
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderCustomizedWithSetterPrefix.Parent build() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public static void test() {
+ Parent x = Parent.builder().setField1(5).build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java
new file mode 100644
index 00000000..28395fcd
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java
@@ -0,0 +1,201 @@
+import java.util.List;
+public class SuperBuilderWithSetterPrefix {
+ public static class Parent {
+ private int field1;
+ int obtainViaField;
+ int obtainViaMethod;
+ String obtainViaStaticMethod;
+ List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaField;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaMethod;
+ @java.lang.SuppressWarnings("all")
+ private String obtainViaStaticMethod;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ b.withField1(instance.field1);
+ b.withObtainViaField(instance.field1);
+ b.withObtainViaMethod(instance.method());
+ b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
+ b.withItems(instance.items == null ? java.util.Collections.emptyList() : instance.items);
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.SuppressWarnings("all")
+ public B withField1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withItem(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withItems(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ", obtainViaField=" + this.obtainViaField + ", obtainViaMethod=" + this.obtainViaMethod + ", obtainViaStaticMethod=" + this.obtainViaStaticMethod + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Parent build() {
+ return new SuperBuilderWithSetterPrefix.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static class Child extends Parent {
+ private double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ b.setField3(instance.field3);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.SuppressWarnings("all")
+ public B setField3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Child build() {
+ return new SuperBuilderWithSetterPrefix.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderCustomized.java b/test/transform/resource/after-ecj/SuperBuilderCustomized.java
index 40d1f384..32317f6a 100644
--- a/test/transform/resource/after-ecj/SuperBuilderCustomized.java
+++ b/test/transform/resource/after-ecj/SuperBuilderCustomized.java
@@ -10,12 +10,12 @@ public class SuperBuilderCustomized {
field1 = 0;
return self();
}
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final int field1) {
- this.field1 = field1;
+ public B field1(int field1) {
+ this.field1 = (field1 + 1);
return self();
}
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("SuperBuilderCustomized.Parent.ParentBuilder(field1=" + this.field1) + ")");
}
diff --git a/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java b/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java
new file mode 100644
index 00000000..283bacd4
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java
@@ -0,0 +1,45 @@
+import java.util.List;
+public class SuperBuilderCustomizedWithSetterPrefix {
+ public static @lombok.experimental.SuperBuilder(setterPrefix = "set") class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ public ParentBuilder() {
+ super();
+ }
+ public B setField1(int field1) {
+ this.field1 = (field1 + 1);
+ return self();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent build() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
+ }
+ }
+ int field1;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public SuperBuilderCustomizedWithSetterPrefix() {
+ super();
+ }
+ public static void test() {
+ Parent x = Parent.builder().setField1(5).build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java
new file mode 100644
index 00000000..6d24f613
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java
@@ -0,0 +1,168 @@
+import java.util.List;
+public class SuperBuilderWithSetterPrefix {
+ public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "with") class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ private @java.lang.SuppressWarnings("all") int obtainViaField;
+ private @java.lang.SuppressWarnings("all") int obtainViaMethod;
+ private @java.lang.SuppressWarnings("all") String obtainViaStaticMethod;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ b.withField1(instance.field1);
+ b.withObtainViaField(instance.field1);
+ b.withObtainViaMethod(instance.method());
+ b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
+ b.withItems(((instance.items == null) ? java.util.Collections.emptyList() : instance.items));
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.SuppressWarnings("all") B withField1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withObtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withObtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withItem(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withItems(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((((((((("SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent build() {
+ return new SuperBuilderWithSetterPrefix.Parent(this);
+ }
+ }
+ private int field1;
+ @lombok.Builder.ObtainVia(field = "field1") int obtainViaField;
+ @lombok.Builder.ObtainVia(method = "method") int obtainViaMethod;
+ @lombok.Builder.ObtainVia(method = "staticMethod",isStatic = true) String obtainViaStaticMethod;
+ @lombok.Singular List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "set") class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ b.setField3(instance.field3);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.SuppressWarnings("all") B setField3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child build() {
+ return new SuperBuilderWithSetterPrefix.Child(this);
+ }
+ }
+ private double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderWithSetterPrefix() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/before/SuperBuilderCustomized.java b/test/transform/resource/before/SuperBuilderCustomized.java
index 58f2797c..77830587 100644
--- a/test/transform/resource/before/SuperBuilderCustomized.java
+++ b/test/transform/resource/before/SuperBuilderCustomized.java
@@ -8,6 +8,10 @@ public class SuperBuilderCustomized {
field1 = 0;
return self();
}
+ public B field1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
}
int field1;
}
diff --git a/test/transform/resource/before/SuperBuilderCustomizedWithSetterPrefix.java b/test/transform/resource/before/SuperBuilderCustomizedWithSetterPrefix.java
new file mode 100644
index 00000000..be2cfc4a
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderCustomizedWithSetterPrefix.java
@@ -0,0 +1,18 @@
+import java.util.List;
+
+public class SuperBuilderCustomizedWithSetterPrefix {
+ @lombok.experimental.SuperBuilder(setterPrefix = "set")
+ public static class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ public B setField1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
+ }
+ int field1;
+ }
+
+ public static void test() {
+ Parent x = Parent.builder().setField1(5).build();
+ }
+}
diff --git a/test/transform/resource/before/SuperBuilderWithSetterPrefix.java b/test/transform/resource/before/SuperBuilderWithSetterPrefix.java
new file mode 100644
index 00000000..5eaef360
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderWithSetterPrefix.java
@@ -0,0 +1,32 @@
+import java.util.List;
+
+public class SuperBuilderWithSetterPrefix {
+ @lombok.experimental.SuperBuilder(toBuilder=true, setterPrefix = "with")
+ public static class Parent {
+ private int field1;
+ @lombok.Builder.ObtainVia(field="field1")
+ int obtainViaField;
+ @lombok.Builder.ObtainVia(method="method")
+ int obtainViaMethod;
+ @lombok.Builder.ObtainVia(method = "staticMethod", isStatic = true)
+ String obtainViaStaticMethod;
+ @lombok.Singular List<String> items;
+
+ private int method() {
+ return 2;
+ }
+
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ }
+
+ @lombok.experimental.SuperBuilder(toBuilder=true, setterPrefix = "set")
+ public static class Child extends Parent {
+ private double field3;
+ }
+
+ public static void test() {
+ Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
+ }
+}