aboutsummaryrefslogtreecommitdiff
path: root/test/transform/resource
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2017-03-22 23:32:28 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-03-22 23:32:28 +0100
commit3b1792c39701fad8a8abc8d0d508b90ab2832e05 (patch)
tree0ad9e05d2fbc8f8603b3f86e445ec66d1386b9fb /test/transform/resource
parent11fdfb56f735dde042aebd9be6e4b488edfa0d84 (diff)
downloadlombok-3b1792c39701fad8a8abc8d0d508b90ab2832e05.tar.gz
lombok-3b1792c39701fad8a8abc8d0d508b90ab2832e05.tar.bz2
lombok-3b1792c39701fad8a8abc8d0d508b90ab2832e05.zip
Added tests to check warnings/errors emitted by Builder.Default support.
Diffstat (limited to 'test/transform/resource')
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaultsWarnings.java71
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaultsWarnings.java58
-rw-r--r--test/transform/resource/before/BuilderDefaultsWarnings.java10
-rw-r--r--test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages6
-rw-r--r--test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages6
5 files changed, 141 insertions, 10 deletions
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<String> 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<String> 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<String> 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<String>();
+ this.items.add(item);
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsWarningsBuilder items(final java.util.Collection<? extends String> items) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ 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<String> 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<String>(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();
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
index 3b93f046..275d6166 100644
--- a/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
+++ b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
@@ -1,8 +1,10 @@
import lombok.Builder;
+import lombok.Singular;
public @Builder class BuilderDefaultsWarnings {
public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") class BuilderDefaultsWarningsBuilder {
private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") long x;
private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int z;
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.util.ArrayList<String> items;
@java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder() {
super();
}
@@ -14,22 +16,72 @@ public @Builder class BuilderDefaultsWarnings {
this.z = z;
return this;
}
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder item(String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder items(java.util.Collection<? extends String> items) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return this;
+ }
public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarnings build() {
- return new BuilderDefaultsWarnings(x, z);
+ java.util.List<String> 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<String>(this.items));
+ }
+ return new BuilderDefaultsWarnings(x, z, items);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") 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) + ")");
}
}
long x = System.currentTimeMillis();
final int y = 5;
@Builder.Default int z;
- @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarnings(final long x, final int z) {
+ @Builder.Default @Singular java.util.List<String> items;
+ @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarnings(final long x, final int z, final java.util.List<String> items) {
super();
this.x = x;
this.z = z;
+ this.items = items;
}
public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder builder() {
return new BuilderDefaultsWarningsBuilder();
}
}
+class NoBuilderButHasDefaults {
+ public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") class NoBuilderButHasDefaultsBuilder {
+ @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") NoBuilderButHasDefaultsBuilder() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") NoBuilderButHasDefaults build() {
+ return new NoBuilderButHasDefaults();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.lang.String toString() {
+ return "NoBuilderButHasDefaults.NoBuilderButHasDefaultsBuilder()";
+ }
+ }
+ private final @Builder.Default long z = 5;
+ public @Builder NoBuilderButHasDefaults() {
+ super();
+ }
+ public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") NoBuilderButHasDefaultsBuilder builder() {
+ return new NoBuilderButHasDefaultsBuilder();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/BuilderDefaultsWarnings.java b/test/transform/resource/before/BuilderDefaultsWarnings.java
index a93f0f17..8ef3dc59 100644
--- a/test/transform/resource/before/BuilderDefaultsWarnings.java
+++ b/test/transform/resource/before/BuilderDefaultsWarnings.java
@@ -1,8 +1,18 @@
import lombok.Builder;
+import lombok.Singular;
@Builder
public class BuilderDefaultsWarnings {
long x = System.currentTimeMillis();
final int y = 5;
@Builder.Default int z;
+ @Builder.Default @Singular java.util.List<String> items;
+}
+
+class NoBuilderButHasDefaults {
+ @Builder.Default private final long z = 5;
+
+ @Builder
+ public NoBuilderButHasDefaults() {
+ }
}
diff --git a/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages b/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages
index 5f607134..bbee62be 100644
--- a/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages
+++ b/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages
@@ -1,2 +1,4 @@
-5 @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. if it is not supposed to be settable during building, add @Builder.Constant.
-7 @Builder.Default requires an initializing expression (' = something;').
+13 @Builder.Default requires @Builder on the class for it to mean anything.
+6 @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. if it is not supposed to be settable during building, add @Builder.Constant.
+8 @Builder.Default requires an initializing expression (' = something;').
+9 @Builder.Default and @Singular cannot be mixed.
diff --git a/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages b/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages
index e369db9c..43f1e553 100644
--- a/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages
+++ b/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages
@@ -1,3 +1,5 @@
-5 @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. if it is not supposed to be settable during building, add @Builder.Constant.
-7 @Builder.Default requires an initializing expression (' = something;').
+6 @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. if it is not supposed to be settable during building, add @Builder.Constant.
+8 @Builder.Default requires an initializing expression (' = something;').
+9 @Builder.Default and @Singular cannot be mixed.
+13 @Builder.Default requires @Builder on the class for it to mean anything.