diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-07-03 05:00:28 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-07-03 05:42:34 +0200 |
commit | 7472672f164460cb8fb45ce941b685f358435374 (patch) | |
tree | b95c8230d88861376059d20eecc3c53ea53f9f4f /test/transform | |
parent | 3987f54b8321ae666cb1c774aef5986df05bf4ad (diff) | |
download | lombok-7472672f164460cb8fb45ce941b685f358435374.tar.gz lombok-7472672f164460cb8fb45ce941b685f358435374.tar.bz2 lombok-7472672f164460cb8fb45ce941b685f358435374.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 ecj.
Diffstat (limited to 'test/transform')
-rw-r--r-- | test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java | 61 | ||||
-rw-r--r-- | test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java | 60 |
2 files changed, 121 insertions, 0 deletions
diff --git a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java new file mode 100644 index 00000000..81d59a37 --- /dev/null +++ b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java @@ -0,0 +1,61 @@ +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Value; +import lombok.Builder; +final @NoArgsConstructor @AllArgsConstructor @Builder @Value class ConstructorsWithBuilderDefaults { + public static @java.lang.SuppressWarnings("all") class ConstructorsWithBuilderDefaultsBuilder { + private @java.lang.SuppressWarnings("all") int x; + private @java.lang.SuppressWarnings("all") boolean x$set; + @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder x(final int x) { + this.x = x; + x$set = true; + return this; + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults build() { + return new ConstructorsWithBuilderDefaults((x$set ? x : ConstructorsWithBuilderDefaults.$default$x())); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder(x=" + this.x) + ")"); + } + } + private final @Builder.Default int x; + private static @java.lang.SuppressWarnings("all") int $default$x() { + return 5; + } + public static @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder builder() { + return new ConstructorsWithBuilderDefaultsBuilder(); + } + public @java.lang.SuppressWarnings("all") int getX() { + return this.x; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") 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; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getX()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("ConstructorsWithBuilderDefaults(x=" + this.getX()) + ")"); + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults() { + super(); + this.x = ConstructorsWithBuilderDefaults.$default$x(); + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults(final int x) { + super(); + this.x = x; + } +} diff --git a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java new file mode 100644 index 00000000..6094e2f4 --- /dev/null +++ b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java @@ -0,0 +1,60 @@ +import lombok.NoArgsConstructor; +import lombok.Value; +import lombok.Builder; +final @Builder @Value class ConstructorsWithBuilderDefaults { + public static @java.lang.SuppressWarnings("all") class ConstructorsWithBuilderDefaultsBuilder { + private @java.lang.SuppressWarnings("all") int x; + private @java.lang.SuppressWarnings("all") boolean x$set; + @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder x(final int x) { + this.x = x; + x$set = true; + return this; + } + public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults build() { + return new ConstructorsWithBuilderDefaults((x$set ? x : ConstructorsWithBuilderDefaults.$default$x())); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder(x=" + this.x) + ")"); + } + } + private final @Builder.Default int x; + private static @java.lang.SuppressWarnings("all") int $default$x() { + return 5; + } + @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults(final int x) { + super(); + this.x = x; + } + public static @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder builder() { + return new ConstructorsWithBuilderDefaultsBuilder(); + } + public @java.lang.SuppressWarnings("all") int getX() { + return this.x; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") 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; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getX()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("ConstructorsWithBuilderDefaults(x=" + this.getX()) + ")"); + } + private @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults() { + super(); + this.x = ConstructorsWithBuilderDefaults.$default$x(); + } +}
\ No newline at end of file |