aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java44
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java23
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularToBuilderWithNull.java4
-rw-r--r--test/transform/resource/after-delombok/BuilderWithToBuilder.java77
-rw-r--r--test/transform/resource/after-ecj/BuilderSingularToBuilderWithNull.java7
-rw-r--r--test/transform/resource/after-ecj/BuilderWithToBuilder.java66
-rw-r--r--test/transform/resource/before/BuilderWithToBuilder.java15
8 files changed, 89 insertions, 148 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 220e0dc0..e98ae4b6 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -5,6 +5,7 @@ Lombok Changelog
* PLATFORM: Support for Eclipse Photon. [Issue #1831](https://github.com/rzwitserloot/lombok/issues/1831)
* FEATURE: The `@FieldNameConstants` feature has been completely redesigned. [Issue #1774](https://github.com/rzwitserloot/lombok/issues/1774) [FieldNameConstants documentation](https://projectlombok.org/features/experimental/FieldNameConstants)
* FEATURE: Lombok's `@NonNull` annotation can now be used on types (annotation on types has been introduced in JDK 8). `@Builder`'s `@Singular` annotation now properly deals with annotations on the generics type on the collection: `@Singular List<@NonNull String> names;` now does the right thing.
+* FEATURE: You can now mix `@SuperBuilder` and `toBuilder`, and `toBuilder` no longer throws `NullPointerException` if an `@Singular`-marked collection field is `null`. [Issue #1324](https://github.com/rzwitserloot/lombok/issues/1324)
* BREAKING CHANGE: Lombok will now always copy specific annotations around (from field to getter, from field to builder 'setter', etcetera): A specific curated list of known annotations where that is the right thing to do (generally, `@NonNull` style annotations from various libraries), as well as any annotations you explicitly list in the `lombok.copyableAnnotations` config key in your `lombok.config` file. Also, lombok is more consistent about copying these annotations. (Previous behaviour: Lombok used to copy any annotation whose simple name was `NonNull`, `Nullable`, or `CheckForNull`). [Issue #1570](https://github.com/rzwitserloot/lombok/issues/1570) and [Issue #1634](https://github.com/rzwitserloot/lombok/issues/1634)
* BUGFIX: When using lombok to compile modularized (`module-info.java`-style) code, if the module name has dots in it, it wouldn't work. [Issue #1808](https://github.com/rzwitserloot/lombok/issues/1808)
* BUGFIX: Errors about lombok not reading a module providing `org.mapstruct.ap.spi` when trying to use lombok in jigsaw-mode on JDK 11. [Issue #1806](https://github.com/rzwitserloot/lombok/issues/1806)
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 09765efc..e22b4ed2 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -25,6 +25,7 @@ import static lombok.eclipse.Eclipse.*;
import static lombok.core.handlers.HandlerUtil.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -46,6 +47,7 @@ import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.IfStatement;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
@@ -502,15 +504,12 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
}
- private static final char[] EMPTY_LIST = "emptyList".toCharArray();
+ private static final char[] BUILDER_TEMP_VAR = {'b', 'u', 'i', 'l', 'd', 'e', 'r'};
private MethodDeclaration generateToBuilderMethod(String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source) {
- // return new ThingieBuilder<A, B>().setA(this.a).setB(this.b);
-
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
- MethodDeclaration out = new MethodDeclaration(
- ((CompilationUnitDeclaration) type.top().get()).compilationResult);
+ MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
out.selector = methodName.toCharArray();
out.modifiers = ClassFileConstants.AccPublic;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
@@ -519,6 +518,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
invoke.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
Expression receiver = invoke;
+ List<Statement> statements = null;
for (BuilderFieldData bfd : builderFields) {
char[] setterName = fluent ? bfd.name : HandlerUtil.buildAccessorName("set", new String(bfd.name)).toCharArray();
MessageSend ms = new MessageSend();
@@ -542,22 +542,34 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
tgt[i] = obtainExpr;
}
}
+
+ ms.selector = setterName;
if (bfd.singularData == null) {
ms.arguments = tgt;
+ ms.receiver = receiver;
+ receiver = ms;
} else {
- Expression ifNull = new EqualExpression(tgt[0], new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL);
- MessageSend emptyList = new MessageSend();
- emptyList.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.UTIL, "Collections".toCharArray());
- emptyList.selector = EMPTY_LIST;
- emptyList.typeArguments = copyTypes(bfd.singularData.getTypeArgs().toArray(new TypeReference[0]));
- ms.arguments = new Expression[] {new ConditionalExpression(ifNull, emptyList, tgt[1])};
+ ms.arguments = new Expression[] {tgt[1]};
+ ms.receiver = new SingleNameReference(BUILDER_TEMP_VAR, p);
+ EqualExpression isNotNull = new EqualExpression(tgt[0], new NullLiteral(pS, pE), OperatorIds.NOT_EQUAL);
+ if (statements == null) statements = new ArrayList<Statement>();
+ statements.add(new IfStatement(isNotNull, ms, pS, pE));
}
- ms.receiver = receiver;
- ms.selector = setterName;
- receiver = ms;
}
- out.statements = new Statement[] {new ReturnStatement(receiver, pS, pE)};
+ if (statements != null) {
+ out.statements = new Statement[statements.size() + 2];
+ for (int i = 0; i < statements.size(); i++) out.statements[i + 1] = statements.get(i);
+ LocalDeclaration b = new LocalDeclaration(BUILDER_TEMP_VAR, pS, pE);
+ out.statements[0] = b;
+ b.modifiers |= Modifier.FINAL;
+ b.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
+ b.type.sourceStart = pS; b.type.sourceEnd = pE;
+ b.initialization = receiver;
+ out.statements[out.statements.length - 1] = new ReturnStatement(new SingleNameReference(BUILDER_TEMP_VAR, p), pS, pE);
+ } else {
+ out.statements = new Statement[] {new ReturnStatement(receiver, pS, pE)};
+ }
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
@@ -617,7 +629,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
inv.typeArguments = typeParameterNames(((TypeDeclaration) type.get()).typeParameters);
args.add(new ConditionalExpression(
- new SingleNameReference(bfd.nameOfSetFlag, 0L),
+ new SingleNameReference(bfd.nameOfSetFlag, 0L),
new SingleNameReference(bfd.name, 0L),
inv));
} else {
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index bc1a8072..c5c1e1ca 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -484,6 +484,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
sb.append("__ERR__");
}
+ private static final String BUILDER_TEMP_VAR = "builder";
private JCMethodDecl generateToBuilderMethod(String toBuilderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, boolean fluent, JCAnnotation ast) {
// return new ThingieBuilder<A, B>().setA(this.a).setB(this.b);
JavacTreeMaker maker = type.getTreeMaker();
@@ -495,6 +496,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), List.<JCExpression>nil(), null);
JCExpression invoke = call;
+ ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
for (BuilderFieldData bfd : builderFields) {
Name setterName = fluent ? bfd.name : type.toName(HandlerUtil.buildAccessorName("set", bfd.name.toString()));
JCExpression[] tgt = new JCExpression[bfd.singularData == null ? 1 : 2];
@@ -519,18 +521,21 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCExpression arg;
if (bfd.singularData == null) {
arg = tgt[0];
+ invoke = maker.Apply(List.<JCExpression>nil(), maker.Select(invoke, setterName), List.of(arg));
} else {
- JCExpression eqNull = maker.Binary(CTC_EQUAL, tgt[0], maker.Literal(CTC_BOT, null));
- List<JCExpression> tas = cloneTypes(maker, bfd.singularData.getTypeArgs(), ast, type.getContext());
- JCExpression emptyList = maker.Apply(tas, chainDots(type, "java", "util", "Collections", "emptyList"), List.<JCExpression>nil());
- arg = maker.Conditional(eqNull, emptyList, tgt[1]);
+ JCExpression isNotNull = maker.Binary(CTC_NOT_EQUAL, tgt[0], maker.Literal(CTC_BOT, null));
+ JCExpression invokeBuilder = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(type.toName(BUILDER_TEMP_VAR)), setterName), List.<JCExpression>of(tgt[1]));
+ statements.append(maker.If(isNotNull, maker.Exec(invokeBuilder), null));
}
-
- invoke = maker.Apply(List.<JCExpression>nil(), maker.Select(invoke, setterName), List.of(arg));
}
- JCStatement statement = maker.Return(invoke);
-
- JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
+ if (!statements.isEmpty()) {
+ JCExpression tempVarType = namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams);
+ statements.prepend(maker.VarDef(maker.Modifiers(Flags.FINAL), type.toName(BUILDER_TEMP_VAR), tempVarType, invoke));
+ statements.append(maker.Return(maker.Ident(type.toName(BUILDER_TEMP_VAR))));
+ } else {
+ statements.append(maker.Return(invoke));
+ }
+ JCBlock body = maker.Block(0, statements.toList());
return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
diff --git a/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNull.java b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNull.java
index b0563858..96ffd2dc 100644
--- a/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNull.java
+++ b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNull.java
@@ -58,6 +58,8 @@ class BuilderSingularToBuilderWithNull {
}
@java.lang.SuppressWarnings("all")
public BuilderSingularToBuilderWithNullBuilder toBuilder() {
- return new BuilderSingularToBuilderWithNullBuilder().elems(this.elems == null ? java.util.Collections.<String>emptyList() : this.elems);
+ final BuilderSingularToBuilderWithNullBuilder builder = new BuilderSingularToBuilderWithNullBuilder();
+ if (this.elems != null) builder.elems(this.elems);
+ return builder;
}
}
diff --git a/test/transform/resource/after-delombok/BuilderWithToBuilder.java b/test/transform/resource/after-delombok/BuilderWithToBuilder.java
index 8615a40b..53256107 100644
--- a/test/transform/resource/after-delombok/BuilderWithToBuilder.java
+++ b/test/transform/resource/after-delombok/BuilderWithToBuilder.java
@@ -86,7 +86,9 @@ class BuilderWithToBuilder<T> {
}
@java.lang.SuppressWarnings("all")
public BuilderWithToBuilderBuilder<T> toBuilder() {
- return new BuilderWithToBuilderBuilder<T>().one(this.mOne).two(this.mTwo).foo(BuilderWithToBuilder.rrr(this)).bars(this.bars == null ? java.util.Collections.<T>emptyList() : this.bars);
+ final BuilderWithToBuilderBuilder<T> builder = new BuilderWithToBuilderBuilder<T>().one(this.mOne).two(this.mTwo).foo(BuilderWithToBuilder.rrr(this));
+ if (this.bars != null) builder.bars(this.bars);
+ return builder;
}
}
class ConstructorWithToBuilder<T> {
@@ -94,15 +96,17 @@ class ConstructorWithToBuilder<T> {
private String mTwo;
private T foo;
@lombok.Singular
- private List<T> bars;
- public ConstructorWithToBuilder(String mOne, T bar) {
+ private com.google.common.collect.ImmutableList<T> bars;
+ public ConstructorWithToBuilder(String mOne, T baz, com.google.common.collect.ImmutableList<T> bars) {
}
@java.lang.SuppressWarnings("all")
public static class ConstructorWithToBuilderBuilder<T> {
@java.lang.SuppressWarnings("all")
private String mOne;
@java.lang.SuppressWarnings("all")
- private T bar;
+ private T baz;
+ @java.lang.SuppressWarnings("all")
+ private com.google.common.collect.ImmutableList<T> bars;
@java.lang.SuppressWarnings("all")
ConstructorWithToBuilderBuilder() {
}
@@ -112,18 +116,23 @@ class ConstructorWithToBuilder<T> {
return this;
}
@java.lang.SuppressWarnings("all")
- public ConstructorWithToBuilderBuilder<T> bar(final T bar) {
- this.bar = bar;
+ public ConstructorWithToBuilderBuilder<T> baz(final T baz) {
+ this.baz = baz;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ public ConstructorWithToBuilderBuilder<T> bars(final com.google.common.collect.ImmutableList<T> bars) {
+ this.bars = bars;
return this;
}
@java.lang.SuppressWarnings("all")
public ConstructorWithToBuilder<T> build() {
- return new ConstructorWithToBuilder<T>(mOne, bar);
+ return new ConstructorWithToBuilder<T>(mOne, baz, bars);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
- return "ConstructorWithToBuilder.ConstructorWithToBuilderBuilder(mOne=" + this.mOne + ", bar=" + this.bar + ")";
+ return "ConstructorWithToBuilder.ConstructorWithToBuilderBuilder(mOne=" + this.mOne + ", baz=" + this.baz + ", bars=" + this.bars + ")";
}
}
@java.lang.SuppressWarnings("all")
@@ -132,54 +141,6 @@ class ConstructorWithToBuilder<T> {
}
@java.lang.SuppressWarnings("all")
public ConstructorWithToBuilderBuilder<T> toBuilder() {
- return new ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).bar(this.foo);
+ return new ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).baz(this.foo).bars(this.bars);
}
-}
-class StaticWithToBuilder<T, K> {
- private String mOne;
- private String mTwo;
- private T foo;
- private K bar;
- @lombok.Singular
- private List<T> bars;
- public static <Z> StaticWithToBuilder<Z, String> test(String mOne, Z bar) {
- return new StaticWithToBuilder<Z, String>();
- }
- @java.lang.SuppressWarnings("all")
- public static class StaticWithToBuilderBuilder<Z> {
- @java.lang.SuppressWarnings("all")
- private String mOne;
- @java.lang.SuppressWarnings("all")
- private Z bar;
- @java.lang.SuppressWarnings("all")
- StaticWithToBuilderBuilder() {
- }
- @java.lang.SuppressWarnings("all")
- public StaticWithToBuilderBuilder<Z> mOne(final String mOne) {
- this.mOne = mOne;
- return this;
- }
- @java.lang.SuppressWarnings("all")
- public StaticWithToBuilderBuilder<Z> bar(final Z bar) {
- this.bar = bar;
- return this;
- }
- @java.lang.SuppressWarnings("all")
- public StaticWithToBuilder<Z, String> build() {
- return StaticWithToBuilder.<Z>test(mOne, bar);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "StaticWithToBuilder.StaticWithToBuilderBuilder(mOne=" + this.mOne + ", bar=" + this.bar + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- public static <Z> StaticWithToBuilderBuilder<Z> builder() {
- return new StaticWithToBuilderBuilder<Z>();
- }
- @java.lang.SuppressWarnings("all")
- public StaticWithToBuilderBuilder<T> toBuilder() {
- return new StaticWithToBuilderBuilder<T>().mOne(this.mOne).bar(this.foo);
- }
-}
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNull.java b/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNull.java
index bbbf9268..ccd6335a 100644
--- a/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNull.java
+++ b/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNull.java
@@ -52,6 +52,9 @@ import lombok.Singular;
return new BuilderSingularToBuilderWithNullBuilder();
}
public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullBuilder toBuilder() {
- return new BuilderSingularToBuilderWithNullBuilder().elems(((this.elems == null) ? java.util.Collections.<String>emptyList() : this.elems));
+ final BuilderSingularToBuilderWithNullBuilder builder = new BuilderSingularToBuilderWithNullBuilder();
+ if ((this.elems != null))
+ builder.elems(this.elems);
+ return builder;
}
-}
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/BuilderWithToBuilder.java b/test/transform/resource/after-ecj/BuilderWithToBuilder.java
index 636dc42d..420f1583 100644
--- a/test/transform/resource/after-ecj/BuilderWithToBuilder.java
+++ b/test/transform/resource/after-ecj/BuilderWithToBuilder.java
@@ -74,13 +74,17 @@ import lombok.Builder;
return new BuilderWithToBuilderBuilder<T>();
}
public @java.lang.SuppressWarnings("all") BuilderWithToBuilderBuilder<T> toBuilder() {
- return new BuilderWithToBuilderBuilder<T>().one(this.mOne).two(this.mTwo).foo(BuilderWithToBuilder.rrr(this)).bars(((this.bars == null) ? java.util.Collections.<T>emptyList() : this.bars));
+ final BuilderWithToBuilderBuilder<T> builder = new BuilderWithToBuilderBuilder<T>().one(this.mOne).two(this.mTwo).foo(BuilderWithToBuilder.rrr(this));
+ if ((this.bars != null))
+ builder.bars(this.bars);
+ return builder;
}
}
@lombok.experimental.Accessors(prefix = "m") class ConstructorWithToBuilder<T> {
public static @java.lang.SuppressWarnings("all") class ConstructorWithToBuilderBuilder<T> {
private @java.lang.SuppressWarnings("all") String mOne;
- private @java.lang.SuppressWarnings("all") T bar;
+ private @java.lang.SuppressWarnings("all") T baz;
+ private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList<T> bars;
@java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder() {
super();
}
@@ -88,68 +92,32 @@ import lombok.Builder;
this.mOne = mOne;
return this;
}
- public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> bar(final T bar) {
- this.bar = bar;
+ public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> baz(final T baz) {
+ this.baz = baz;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> bars(final com.google.common.collect.ImmutableList<T> bars) {
+ this.bars = bars;
return this;
}
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilder<T> build() {
- return new ConstructorWithToBuilder<T>(mOne, bar);
+ return new ConstructorWithToBuilder<T>(mOne, baz, bars);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("ConstructorWithToBuilder.ConstructorWithToBuilderBuilder(mOne=" + this.mOne) + ", bar=") + this.bar) + ")");
+ return (((((("ConstructorWithToBuilder.ConstructorWithToBuilderBuilder(mOne=" + this.mOne) + ", baz=") + this.baz) + ", bars=") + this.bars) + ")");
}
}
private String mOne;
private String mTwo;
private T foo;
- private @lombok.Singular List<T> bars;
- public @Builder(toBuilder = true) ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T bar) {
+ private @lombok.Singular com.google.common.collect.ImmutableList<T> bars;
+ public @Builder(toBuilder = true) ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
super();
}
public static @java.lang.SuppressWarnings("all") <T>ConstructorWithToBuilderBuilder<T> builder() {
return new ConstructorWithToBuilderBuilder<T>();
}
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> toBuilder() {
- return new ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).bar(this.foo);
- }
-}
-@lombok.experimental.Accessors(prefix = "m") class StaticWithToBuilder<T, K> {
- public static @java.lang.SuppressWarnings("all") class StaticWithToBuilderBuilder<Z> {
- private @java.lang.SuppressWarnings("all") String mOne;
- private @java.lang.SuppressWarnings("all") Z bar;
- @java.lang.SuppressWarnings("all") StaticWithToBuilderBuilder() {
- super();
- }
- public @java.lang.SuppressWarnings("all") StaticWithToBuilderBuilder<Z> mOne(final String mOne) {
- this.mOne = mOne;
- return this;
- }
- public @java.lang.SuppressWarnings("all") StaticWithToBuilderBuilder<Z> bar(final Z bar) {
- this.bar = bar;
- return this;
- }
- public @java.lang.SuppressWarnings("all") StaticWithToBuilder<Z, String> build() {
- return StaticWithToBuilder.<Z>test(mOne, bar);
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("StaticWithToBuilder.StaticWithToBuilderBuilder(mOne=" + this.mOne) + ", bar=") + this.bar) + ")");
- }
- }
- private String mOne;
- private String mTwo;
- private T foo;
- private K bar;
- private @lombok.Singular List<T> bars;
- StaticWithToBuilder() {
- super();
- }
- public static @Builder(toBuilder = true) <Z>StaticWithToBuilder<Z, String> test(String mOne, @Builder.ObtainVia(field = "foo") Z bar) {
- return new StaticWithToBuilder<Z, String>();
- }
- public static @java.lang.SuppressWarnings("all") <Z>StaticWithToBuilderBuilder<Z> builder() {
- return new StaticWithToBuilderBuilder<Z>();
- }
- public @java.lang.SuppressWarnings("all") StaticWithToBuilderBuilder<T> toBuilder() {
- return new StaticWithToBuilderBuilder<T>().mOne(this.mOne).bar(this.foo);
+ return new ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).baz(this.foo).bars(this.bars);
}
}
diff --git a/test/transform/resource/before/BuilderWithToBuilder.java b/test/transform/resource/before/BuilderWithToBuilder.java
index 63e16ae8..50938ab2 100644
--- a/test/transform/resource/before/BuilderWithToBuilder.java
+++ b/test/transform/resource/before/BuilderWithToBuilder.java
@@ -13,19 +13,8 @@ class BuilderWithToBuilder<T> {
class ConstructorWithToBuilder<T> {
private String mOne, mTwo;
private T foo;
- @lombok.Singular private List<T> bars;
- @Builder(toBuilder = true)
- public ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T bar) {
- }
-}
-@lombok.experimental.Accessors(prefix = "m")
-class StaticWithToBuilder<T, K> {
- private String mOne, mTwo;
- private T foo;
- private K bar;
- @lombok.Singular private List<T> bars;
+ @lombok.Singular private com.google.common.collect.ImmutableList<T> bars;
@Builder(toBuilder = true)
- public static <Z> StaticWithToBuilder<Z, String> test(String mOne, @Builder.ObtainVia(field = "foo") Z bar) {
- return new StaticWithToBuilder<Z, String>();
+ public ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
}
}