From 3b1792c39701fad8a8abc8d0d508b90ab2832e05 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 22 Mar 2017 23:32:28 +0100 Subject: Added tests to check warnings/errors emitted by Builder.Default support. --- .../after-delombok/BuilderDefaultsWarnings.java | 71 +++++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'test/transform/resource/after-delombok') diff --git a/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java index e8247f52..ccc39a9e 100644 --- a/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java +++ b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java @@ -2,11 +2,13 @@ public class BuilderDefaultsWarnings { long x = System.currentTimeMillis(); final int y = 5; int z; + java.util.List items; @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") - BuilderDefaultsWarnings(final long x, final int z) { + BuilderDefaultsWarnings(final long x, final int z, final java.util.List items) { this.x = x; this.z = z; + this.items = items; } @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") @@ -19,6 +21,9 @@ public class BuilderDefaultsWarnings { private int z; @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") + private java.util.ArrayList items; + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder() { } @java.lang.SuppressWarnings("all") @@ -35,14 +40,45 @@ public class BuilderDefaultsWarnings { } @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") + public BuilderDefaultsWarningsBuilder item(final String item) { + if (this.items == null) this.items = new java.util.ArrayList(); + this.items.add(item); + return this; + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public BuilderDefaultsWarningsBuilder items(final java.util.Collection items) { + if (this.items == null) this.items = new java.util.ArrayList(); + this.items.addAll(items); + return this; + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public BuilderDefaultsWarningsBuilder clearItems() { + if (this.items != null) this.items.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") public BuilderDefaultsWarnings build() { - return new BuilderDefaultsWarnings(x, z); + java.util.List items; + switch (this.items == null ? 0 : this.items.size()) { + case 0: + items = java.util.Collections.emptyList(); + break; + case 1: + items = java.util.Collections.singletonList(this.items.get(0)); + break; + default: + items = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.items)); + } + return new BuilderDefaultsWarnings(x, z, items); } @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") public java.lang.String toString() { - return "BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder(x=" + this.x + ", z=" + this.z + ")"; + return "BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder(x=" + this.x + ", z=" + this.z + ", items=" + this.items + ")"; } } @java.lang.SuppressWarnings("all") @@ -51,3 +87,32 @@ public class BuilderDefaultsWarnings { return new BuilderDefaultsWarningsBuilder(); } } +class NoBuilderButHasDefaults { + private final long z = 5; + public NoBuilderButHasDefaults() { + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public static class NoBuilderButHasDefaultsBuilder { + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + NoBuilderButHasDefaultsBuilder() { + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public NoBuilderButHasDefaults build() { + return new NoBuilderButHasDefaults(); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public java.lang.String toString() { + return "NoBuilderButHasDefaults.NoBuilderButHasDefaultsBuilder()"; + } + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public static NoBuilderButHasDefaultsBuilder builder() { + return new NoBuilderButHasDefaultsBuilder(); + } +} -- cgit