From 3eea3b958946dd813197f00a1292b7a72380878a Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot <reinier@zwitserloot.com>
Date: Wed, 4 Apr 2018 23:26:01 +0200
Subject: introduction of `@SuperBuilder` and a testcase.

---
 .../resource/after-delombok/SuperBuilderBasic.java | 112 +++++++++++++++++++++
 .../resource/before/BuilderWithInherit.java        |  20 ----
 .../resource/before/SuperBuilderBasic.java         |  20 ++++
 3 files changed, 132 insertions(+), 20 deletions(-)
 create mode 100644 test/transform/resource/after-delombok/SuperBuilderBasic.java
 delete mode 100644 test/transform/resource/before/BuilderWithInherit.java
 create mode 100644 test/transform/resource/before/SuperBuilderBasic.java

(limited to 'test')

diff --git a/test/transform/resource/after-delombok/SuperBuilderBasic.java b/test/transform/resource/after-delombok/SuperBuilderBasic.java
new file mode 100644
index 00000000..ffb56e0e
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderBasic.java
@@ -0,0 +1,112 @@
+import java.util.List;
+
+public class SuperBuilderBasic {
+	public static class Parent {
+		int field1;
+		List<String> items;
+		protected Parent(final ParentBuilder<?, ?> b) {
+			this.field1 = b.field1;
+			java.util.List<String> items;
+			switch (b.items == null ? 0 : b.items.size()) {
+			case 0: 
+				items = java.util.Collections.emptyList();
+				break;
+			case 1: 
+				items = java.util.Collections.singletonList(b.items.get(0));
+				break;
+			default: 
+				items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+			}
+			this.items = items;
+		}
+		private static class ParentBuilderImpl extends ParentBuilder<Parent, ParentBuilderImpl> {
+			@Override
+			public Parent build() {
+				return new Parent(this);
+			}
+			
+			@Override
+			public ParentBuilderImpl self() {
+				return this;
+			}
+		}
+		public abstract static class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+			@java.lang.SuppressWarnings("all")
+			private int field1;
+			@java.lang.SuppressWarnings("all")
+			private java.util.ArrayList<String> items;
+			@java.lang.SuppressWarnings("all")
+			ParentBuilder() {
+			}
+			@java.lang.SuppressWarnings("all")
+			public B field1(final int field1) {
+				this.field1 = field1;
+				return self();
+			}
+			@java.lang.SuppressWarnings("all")
+			public B item(final String item) {
+				if (this.items == null) this.items = new java.util.ArrayList<String>();
+				this.items.add(item);
+				return self();
+			}
+			@java.lang.SuppressWarnings("all")
+			public B items(final java.util.Collection<? extends String> items) {
+				if (this.items == null) this.items = new java.util.ArrayList<String>();
+				this.items.addAll(items);
+				return self();
+			}
+			@java.lang.SuppressWarnings("all")
+			public B clearItems() {
+				if (this.items != null) this.items.clear();
+				return self();
+			}
+			@java.lang.SuppressWarnings("all")
+			protected abstract B self();
+			@java.lang.SuppressWarnings("all")
+			public abstract C build();
+		}
+		public static ParentBuilder<?, ?> builder() {
+			return new ParentBuilderImpl();
+		}
+	}
+	public static class Child extends Parent {
+		double field3;
+		protected Child(ChildBuilder<?, ?> b) {
+			super(b);
+			this.field3 = b.field3;
+		}
+		private static class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
+			@Override
+			public Child build() {
+				return new Child(this);
+			}
+			
+			@Override
+			public ChildBuilderImpl self() {
+				return this;
+			}
+		}
+		public abstract static class ChildBuilder<C extends Child, B extends ChildBuilder<C, B>> extends Parent.ParentBuilder<Child, B> {
+			@java.lang.SuppressWarnings("all")
+			private double field3;
+			@java.lang.SuppressWarnings("all")
+			ChildBuilder() {
+			}
+			@java.lang.SuppressWarnings("all")
+			public B field3(final double field3) {
+				this.field3 = field3;
+				return self();
+			}
+			@java.lang.SuppressWarnings("all")
+			protected abstract B self();
+			@java.lang.SuppressWarnings("all")
+			public abstract C build();
+		}
+		public static ChildBuilder<?, ?> builder() {
+			return new ChildBuilderImpl();
+		}
+	}
+	public static void test() {
+		Child x = Child.builder().field3(0.0).field1(5).item("").build();
+	}
+}
diff --git a/test/transform/resource/before/BuilderWithInherit.java b/test/transform/resource/before/BuilderWithInherit.java
deleted file mode 100644
index dcc7b5ad..00000000
--- a/test/transform/resource/before/BuilderWithInherit.java
+++ /dev/null
@@ -1,20 +0,0 @@
-import lombok.Builder;
-import lombok.Singular;
-import java.util.List;
-
-public class BuilderWithInherit {
-	@Builder(extensible = true)
-	public static class Parent {
-		int field1;
-		@Singular List<String> items;
-	}
-	
-	@Builder(inherit = true)
-	public static class Child extends Parent {
-		double field3;
-	}
-	
-	public static void test() {
-		Child x = Child.builder().field3(0.0).field1(5).item("").build();
-	}
-}
diff --git a/test/transform/resource/before/SuperBuilderBasic.java b/test/transform/resource/before/SuperBuilderBasic.java
new file mode 100644
index 00000000..bf3eea64
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderBasic.java
@@ -0,0 +1,20 @@
+import lombok.experimental.SuperBuilder;
+import lombok.Singular;
+import java.util.List;
+
+public class SuperBuilderBasic {
+	@SuperBuilder
+	public static class Parent {
+		int field1;
+		@Singular List<String> items;
+	}
+	
+	@SuperBuilder
+	public static class Child extends Parent {
+		double field3;
+	}
+	
+	public static void test() {
+		Child x = Child.builder().field3(0.0).field1(5).item("").build();
+	}
+}
-- 
cgit