diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-07-03 04:17:47 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-07-03 05:42:34 +0200 |
commit | 3987f54b8321ae666cb1c774aef5986df05bf4ad (patch) | |
tree | da0c53aa062e8e0168d22564995ba6de61577ceb /test/transform/resource/after-delombok | |
parent | 577ce94facde1092ab2eec9de12270183e8048bc (diff) | |
download | lombok-3987f54b8321ae666cb1c774aef5986df05bf4ad.tar.gz lombok-3987f54b8321ae666cb1c774aef5986df05bf4ad.tar.bz2 lombok-3987f54b8321ae666cb1c774aef5986df05bf4ad.zip |
[issue #1347] When lombok generates constructors, it should call the `@Builder.Default` static method instead of initializing to null/0/false. This does that, for javac.
Diffstat (limited to 'test/transform/resource/after-delombok')
-rw-r--r-- | test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java | 72 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java | 74 |
2 files changed, 146 insertions, 0 deletions
diff --git a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java new file mode 100644 index 00000000..bd934b44 --- /dev/null +++ b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java @@ -0,0 +1,72 @@ +final class ConstructorsWithBuilderDefaults { + private final int x; + @java.lang.SuppressWarnings("all") + private static int $default$x() { + return 5; + } + @java.lang.SuppressWarnings("all") + public static class ConstructorsWithBuilderDefaultsBuilder { + @java.lang.SuppressWarnings("all") + private boolean x$set; + @java.lang.SuppressWarnings("all") + private int x; + @java.lang.SuppressWarnings("all") + ConstructorsWithBuilderDefaultsBuilder() { + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaultsBuilder x(final int x) { + this.x = x; + x$set = true; + return this; + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaults build() { + int x = this.x; + if (!x$set) x = ConstructorsWithBuilderDefaults.$default$x(); + return new ConstructorsWithBuilderDefaults(x); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder(x=" + this.x + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static ConstructorsWithBuilderDefaultsBuilder builder() { + return new ConstructorsWithBuilderDefaultsBuilder(); + } + @java.lang.SuppressWarnings("all") + public int getX() { + return this.x; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof ConstructorsWithBuilderDefaults)) return false; + final ConstructorsWithBuilderDefaults other = (ConstructorsWithBuilderDefaults) o; + if (this.getX() != other.getX()) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getX(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "ConstructorsWithBuilderDefaults(x=" + this.getX() + ")"; + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaults() { + this.x = ConstructorsWithBuilderDefaults.$default$x(); + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaults(final int x) { + this.x = x; + } +} diff --git a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java new file mode 100644 index 00000000..2576e2a9 --- /dev/null +++ b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java @@ -0,0 +1,74 @@ +//CONF: lombok.noArgsConstructor.extraPrivate = true +import lombok.NoArgsConstructor; +final class ConstructorsWithBuilderDefaults { + private final int x; + @java.lang.SuppressWarnings("all") + private static int $default$x() { + return 5; + } + @java.lang.SuppressWarnings("all") + ConstructorsWithBuilderDefaults(final int x) { + this.x = x; + } + @java.lang.SuppressWarnings("all") + public static class ConstructorsWithBuilderDefaultsBuilder { + @java.lang.SuppressWarnings("all") + private boolean x$set; + @java.lang.SuppressWarnings("all") + private int x; + @java.lang.SuppressWarnings("all") + ConstructorsWithBuilderDefaultsBuilder() { + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaultsBuilder x(final int x) { + this.x = x; + x$set = true; + return this; + } + @java.lang.SuppressWarnings("all") + public ConstructorsWithBuilderDefaults build() { + int x = this.x; + if (!x$set) x = ConstructorsWithBuilderDefaults.$default$x(); + return new ConstructorsWithBuilderDefaults(x); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder(x=" + this.x + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static ConstructorsWithBuilderDefaultsBuilder builder() { + return new ConstructorsWithBuilderDefaultsBuilder(); + } + @java.lang.SuppressWarnings("all") + private ConstructorsWithBuilderDefaults() { + this.x = ConstructorsWithBuilderDefaults.$default$x(); + } + @java.lang.SuppressWarnings("all") + public int getX() { + return this.x; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof ConstructorsWithBuilderDefaults)) return false; + final ConstructorsWithBuilderDefaults other = (ConstructorsWithBuilderDefaults) o; + if (this.getX() != other.getX()) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getX(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "ConstructorsWithBuilderDefaults(x=" + this.getX() + ")"; + } +}
\ No newline at end of file |