diff options
author | Jan Rieke <rieke@subshell.com> | 2018-10-12 19:47:40 +0200 |
---|---|---|
committer | Jan Rieke <rieke@subshell.com> | 2018-10-12 19:47:40 +0200 |
commit | e9d098a16c6b07fb39905ce154f810255a0dfc8f (patch) | |
tree | 11deb46c98105682d0a6ae3530313d0b9fc671c1 | |
parent | 80b5f8d41de3be9f93f49a3d5c2611405b2b1a6f (diff) | |
download | lombok-e9d098a16c6b07fb39905ce154f810255a0dfc8f.tar.gz lombok-e9d098a16c6b07fb39905ce154f810255a0dfc8f.tar.bz2 lombok-e9d098a16c6b07fb39905ce154f810255a0dfc8f.zip |
fixed toBuilder on Singular fields with wildcards (ecj)
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleBuilder.java | 2 | ||||
-rw-r--r-- | test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilder.java | 87 |
2 files changed, 88 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index 5fb98800..86c1da42 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -559,7 +559,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { 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])); + emptyList.typeArguments = bfd.singularData.getSingularizer().createTypeArgs(bfd.singularData.getTypeArgs().size(), false, type, bfd.singularData.getTypeArgs()); ms.arguments = new Expression[] {new ConditionalExpression(ifNull, emptyList, tgt[1])}; } ms.receiver = receiver; diff --git a/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilder.java b/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilder.java new file mode 100644 index 00000000..e8db5ffd --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilder.java @@ -0,0 +1,87 @@ +import java.util.List; +import java.util.Collection; +import lombok.Singular; +@lombok.Builder(toBuilder = true) class BuilderSingularWildcardListsWithToBuilder { + public static @java.lang.SuppressWarnings("all") class BuilderSingularWildcardListsWithToBuilderBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList<java.lang.Object> objects; + private @java.lang.SuppressWarnings("all") java.util.ArrayList<Number> numbers; + @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder object(final java.lang.Object object) { + if ((this.objects == null)) + this.objects = new java.util.ArrayList<java.lang.Object>(); + this.objects.add(object); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder objects(final java.util.Collection<?> objects) { + if ((this.objects == null)) + this.objects = new java.util.ArrayList<java.lang.Object>(); + this.objects.addAll(objects); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder clearObjects() { + if ((this.objects != null)) + this.objects.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder number(final Number number) { + if ((this.numbers == null)) + this.numbers = new java.util.ArrayList<Number>(); + this.numbers.add(number); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder numbers(final java.util.Collection<? extends Number> numbers) { + if ((this.numbers == null)) + this.numbers = new java.util.ArrayList<Number>(); + this.numbers.addAll(numbers); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder clearNumbers() { + if ((this.numbers != null)) + this.numbers.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilder build() { + java.util.List<java.lang.Object> objects; + switch (((this.objects == null) ? 0 : this.objects.size())) { + case 0 : + objects = java.util.Collections.emptyList(); + break; + case 1 : + objects = java.util.Collections.singletonList(this.objects.get(0)); + break; + default : + objects = java.util.Collections.unmodifiableList(new java.util.ArrayList<java.lang.Object>(this.objects)); + } + java.util.Collection<Number> numbers; + switch (((this.numbers == null) ? 0 : this.numbers.size())) { + case 0 : + numbers = java.util.Collections.emptyList(); + break; + case 1 : + numbers = java.util.Collections.singletonList(this.numbers.get(0)); + break; + default : + numbers = java.util.Collections.unmodifiableList(new java.util.ArrayList<Number>(this.numbers)); + } + return new BuilderSingularWildcardListsWithToBuilder(objects, numbers); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderSingularWildcardListsWithToBuilder.BuilderSingularWildcardListsWithToBuilderBuilder(objects=" + this.objects) + ", numbers=") + this.numbers) + ")"); + } + } + private @Singular List<?> objects; + private @Singular Collection<? extends Number> numbers; + @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilder(final List<?> objects, final Collection<? extends Number> numbers) { + super(); + this.objects = objects; + this.numbers = numbers; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder builder() { + return new BuilderSingularWildcardListsWithToBuilderBuilder(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderBuilder toBuilder() { + return new BuilderSingularWildcardListsWithToBuilderBuilder().objects(((this.objects == null) ? java.util.Collections.<java.lang.Object>emptyList() : this.objects)).numbers(((this.numbers == null) ? java.util.Collections.<Number>emptyList() : this.numbers)); + } +}
\ No newline at end of file |