aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2017-03-20 22:54:36 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-03-20 22:54:36 +0100
commitbf54986e8a08d246877fae902c58dc41ca2f559b (patch)
treef1f05e8d65e35aa0627c69c9fc8ad0d1a69e38b0 /test
parentc63c1528843a3ac591c9fbd2db3732af8824d097 (diff)
downloadlombok-bf54986e8a08d246877fae902c58dc41ca2f559b.tar.gz
lombok-bf54986e8a08d246877fae902c58dc41ca2f559b.tar.bz2
lombok-bf54986e8a08d246877fae902c58dc41ca2f559b.zip
Fixing issue #1201: Builder now supports defaults!
Diffstat (limited to 'test')
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaults.java129
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaultsWarnings.java53
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaults.java90
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaultsWarnings.java35
-rw-r--r--test/transform/resource/before/BuilderDefaults.java9
-rw-r--r--test/transform/resource/before/BuilderDefaultsWarnings.java8
-rw-r--r--test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages8
-rw-r--r--test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages3
-rw-r--r--test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages8
10 files changed, 337 insertions, 8 deletions
diff --git a/test/transform/resource/after-delombok/BuilderDefaults.java b/test/transform/resource/after-delombok/BuilderDefaults.java
new file mode 100644
index 00000000..c5c8006a
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderDefaults.java
@@ -0,0 +1,129 @@
+public final class BuilderDefaults {
+ private final int x;
+ private final String name;
+ private final long z;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private static int $default$x() {
+ return 10;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private static long $default$z() {
+ return System.currentTimeMillis();
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ BuilderDefaults(final int x, final String name, final long z) {
+ this.x = x;
+ this.name = name;
+ this.z = z;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public static class BuilderDefaultsBuilder {
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private boolean x$set;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private int x;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private String name;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private boolean z$set;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private long z;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ BuilderDefaultsBuilder() {
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsBuilder x(final int x) {
+ this.x = x;
+ x$set = true;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsBuilder name(final String name) {
+ this.name = name;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsBuilder z(final long z) {
+ this.z = z;
+ z$set = true;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaults build() {
+ return new BuilderDefaults(x$set ? x : BuilderDefaults.$default$x(), name, z$set ? z : BuilderDefaults.$default$z());
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public java.lang.String toString() {
+ return "BuilderDefaults.BuilderDefaultsBuilder(x=" + this.x + ", name=" + this.name + ", z=" + this.z + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public static BuilderDefaultsBuilder builder() {
+ return new BuilderDefaultsBuilder();
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public int getX() {
+ return this.x;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public String getName() {
+ return this.name;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public long getZ() {
+ return this.z;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof BuilderDefaults)) return false;
+ final BuilderDefaults other = (BuilderDefaults) o;
+ if (this.getX() != other.getX()) return false;
+ final java.lang.Object this$name = this.getName();
+ final java.lang.Object other$name = other.getName();
+ if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
+ if (this.getZ() != other.getZ()) return false;
+ return true;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getX();
+ final java.lang.Object $name = this.getName();
+ result = result * PRIME + ($name == null ? 43 : $name.hashCode());
+ final long $z = this.getZ();
+ result = result * PRIME + (int) ($z >>> 32 ^ $z);
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public java.lang.String toString() {
+ return "BuilderDefaults(x=" + this.getX() + ", name=" + this.getName() + ", z=" + this.getZ() + ")";
+ }
+}
diff --git a/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java
new file mode 100644
index 00000000..e8247f52
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java
@@ -0,0 +1,53 @@
+public class BuilderDefaultsWarnings {
+ long x = System.currentTimeMillis();
+ final int y = 5;
+ int z;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ BuilderDefaultsWarnings(final long x, final int z) {
+ this.x = x;
+ this.z = z;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public static class BuilderDefaultsWarningsBuilder {
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private long x;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ private int z;
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ BuilderDefaultsWarningsBuilder() {
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsWarningsBuilder x(final long x) {
+ this.x = x;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsWarningsBuilder z(final int z) {
+ this.z = z;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public BuilderDefaultsWarnings build() {
+ return new BuilderDefaultsWarnings(x, z);
+ }
+ @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 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public static BuilderDefaultsWarningsBuilder builder() {
+ return new BuilderDefaultsWarningsBuilder();
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderDefaults.java b/test/transform/resource/after-ecj/BuilderDefaults.java
new file mode 100644
index 00000000..96903dca
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderDefaults.java
@@ -0,0 +1,90 @@
+import lombok.Builder;
+import lombok.Value;
+public final @Value @Builder class BuilderDefaults {
+ public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") class BuilderDefaultsBuilder {
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int x;
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") boolean x$set;
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") String name;
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") long z;
+ private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") boolean z$set;
+ @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsBuilder() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsBuilder x(final int x) {
+ this.x = x;
+ x$set = true;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsBuilder name(final String name) {
+ this.name = name;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsBuilder z(final long z) {
+ this.z = z;
+ z$set = true;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaults build() {
+ return new BuilderDefaults((x$set ? x : BuilderDefaults.$default$x()), name, (z$set ? z : BuilderDefaults.$default$z()));
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.lang.String toString() {
+ return (((((("BuilderDefaults.BuilderDefaultsBuilder(x=" + this.x) + ", name=") + this.name) + ", z=") + this.z) + ")");
+ }
+ }
+ private final @Builder.Default int x;
+ private final String name;
+ private final @Builder.Default long z;
+ private static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int $default$x() {
+ return 10;
+ }
+ private static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") long $default$z() {
+ return System.currentTimeMillis();
+ }
+ @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaults(final int x, final String name, final long z) {
+ super();
+ this.x = x;
+ this.name = name;
+ this.z = z;
+ }
+ public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsBuilder builder() {
+ return new BuilderDefaultsBuilder();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getX() {
+ return this.x;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") String getName() {
+ return this.name;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") long getZ() {
+ return this.z;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof BuilderDefaults)))
+ return false;
+ final BuilderDefaults other = (BuilderDefaults) o;
+ if ((this.getX() != other.getX()))
+ return false;
+ final java.lang.Object this$name = this.getName();
+ final java.lang.Object other$name = other.getName();
+ if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name))))
+ return false;
+ if ((this.getZ() != other.getZ()))
+ return false;
+ return true;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getX());
+ final java.lang.Object $name = this.getName();
+ result = ((result * PRIME) + (($name == null) ? 43 : $name.hashCode()));
+ final long $z = this.getZ();
+ result = ((result * PRIME) + (int) ($z ^ ($z >>> 32)));
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.lang.String toString() {
+ return (((((("BuilderDefaults(x=" + this.getX()) + ", name=") + this.getName()) + ", z=") + this.getZ()) + ")");
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
new file mode 100644
index 00000000..3b93f046
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
@@ -0,0 +1,35 @@
+import lombok.Builder;
+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;
+ @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder x(final long x) {
+ this.x = x;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder z(final int z) {
+ this.z = z;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarnings build() {
+ return new BuilderDefaultsWarnings(x, z);
+ }
+ 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) + ")");
+ }
+ }
+ 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) {
+ super();
+ this.x = x;
+ this.z = z;
+ }
+ public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderDefaultsWarningsBuilder builder() {
+ return new BuilderDefaultsWarningsBuilder();
+ }
+}
diff --git a/test/transform/resource/before/BuilderDefaults.java b/test/transform/resource/before/BuilderDefaults.java
new file mode 100644
index 00000000..a1ce14a5
--- /dev/null
+++ b/test/transform/resource/before/BuilderDefaults.java
@@ -0,0 +1,9 @@
+import lombok.Builder;
+import lombok.Value;
+
+@Value @Builder
+public class BuilderDefaults {
+ @Builder.Default int x = 10;
+ String name;
+ @Builder.Default long z = System.currentTimeMillis();
+}
diff --git a/test/transform/resource/before/BuilderDefaultsWarnings.java b/test/transform/resource/before/BuilderDefaultsWarnings.java
new file mode 100644
index 00000000..a93f0f17
--- /dev/null
+++ b/test/transform/resource/before/BuilderDefaultsWarnings.java
@@ -0,0 +1,8 @@
+import lombok.Builder;
+
+@Builder
+public class BuilderDefaultsWarnings {
+ long x = System.currentTimeMillis();
+ final int y = 5;
+ @Builder.Default int z;
+}
diff --git a/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages b/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages
new file mode 100644
index 00000000..5f607134
--- /dev/null
+++ b/test/transform/resource/messages-delombok/BuilderDefaultsWarnings.java.messages
@@ -0,0 +1,2 @@
+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;').
diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages
index 6a181265..3386b565 100644
--- a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages
+++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages
@@ -1,4 +1,4 @@
-2 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-3 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-4 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-5 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
+3 The correct format is
+4 The correct format is
+5 The correct format is
+6 The correct format is
diff --git a/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages b/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages
new file mode 100644
index 00000000..e369db9c
--- /dev/null
+++ b/test/transform/resource/messages-ecj/BuilderDefaultsWarnings.java.messages
@@ -0,0 +1,3 @@
+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;').
+
diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages
index 6a181265..3386b565 100644
--- a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages
+++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages
@@ -1,4 +1,4 @@
-2 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-3 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-4 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
-5 The correct format is @Getter(onMethod_={@SomeAnnotation, @SomeOtherAnnotation})
+3 The correct format is
+4 The correct format is
+5 The correct format is
+6 The correct format is