From f072827630bfbdc548bc739fa979308cc2c4d3fb Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Thu, 16 Aug 2018 14:38:44 +0200 Subject: @SuperBuilder adapts @Builder.Default behavior from @Builder as #1347 is fixed now (javac) --- .../after-delombok/SuperBuilderWithDefaults.java | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java index 7b6b4578..06d88f4d 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java @@ -1,8 +1,16 @@ import java.util.List; public class SuperBuilderWithDefaults { public static class Parent { - private long millis = System.currentTimeMillis(); - private N numberField = null; + private long millis; + private N numberField; + @java.lang.SuppressWarnings("all") + private static long $default$millis() { + return System.currentTimeMillis(); + } + @java.lang.SuppressWarnings("all") + private static N $default$numberField() { + return null; + } @java.lang.SuppressWarnings("all") public static abstract class ParentBuilder, B extends ParentBuilder> { @java.lang.SuppressWarnings("all") @@ -53,8 +61,10 @@ public class SuperBuilderWithDefaults { } @java.lang.SuppressWarnings("all") protected Parent(final ParentBuilder b) { - if (b.millis$set) this.millis = b.millis; - if (b.numberField$set) this.numberField = b.numberField; + this.millis = b.millis; + if (!b.millis$set) this.millis = Parent.$default$millis(); + this.numberField = b.numberField; + if (!b.numberField$set) this.numberField = Parent.$default$numberField(); } @java.lang.SuppressWarnings("all") public static ParentBuilder builder() { @@ -62,7 +72,11 @@ public class SuperBuilderWithDefaults { } } public static class Child extends Parent { - private double doubleField = Math.PI; + private double doubleField; + @java.lang.SuppressWarnings("all") + private static double $default$doubleField() { + return Math.PI; + } @java.lang.SuppressWarnings("all") public static abstract class ChildBuilder> extends Parent.ParentBuilder { @java.lang.SuppressWarnings("all") @@ -106,7 +120,8 @@ public class SuperBuilderWithDefaults { @java.lang.SuppressWarnings("all") protected Child(final ChildBuilder b) { super(b); - if (b.doubleField$set) this.doubleField = b.doubleField; + this.doubleField = b.doubleField; + if (!b.doubleField$set) this.doubleField = Child.$default$doubleField(); } @java.lang.SuppressWarnings("all") public static ChildBuilder builder() { -- cgit