mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 02:17:12 +00:00
@SuperBuilder adapts @Builder.Default behavior from @Builder as #1347 is
fixed now (javac)
This commit is contained in:
1 parent
c21adf7f47
commit
dbc173ba5c
3 files changed
+36
-24
No files matched your search
@@ -1,8 +1,16 @@
|
||||
import java.util.List;
|
||||
public class SuperBuilderWithDefaults {
|
||||
public static class Parent<N extends Number> {
|
||||
private long millis = System.currentTimeMillis();
|
||||
private N numberField = null;
|
||||
private long millis;
|
||||
private N numberField;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static <N extends Number> long $default$millis() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static <N extends Number> N $default$numberField() {
|
||||
return null;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static abstract class ParentBuilder<N extends Number, C extends Parent<N>, B extends ParentBuilder<N, C, B>> {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@@ -53,8 +61,10 @@ public class SuperBuilderWithDefaults {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
protected Parent(final ParentBuilder<N, ?, ?> 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.<N>$default$millis();
|
||||
this.numberField = b.numberField;
|
||||
if (!b.numberField$set) this.numberField = Parent.<N>$default$numberField();
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static <N extends Number> ParentBuilder<N, ?, ?> builder() {
|
||||
@@ -62,7 +72,11 @@ public class SuperBuilderWithDefaults {
|
||||
}
|
||||
}
|
||||
public static class Child extends Parent<Integer> {
|
||||
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<C extends Child, B extends ChildBuilder<C, B>> extends Parent.ParentBuilder<Integer, C, B> {
|
||||
@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() {
|
||||
|
||||
Reference in new issue
Block a user