aboutsummaryrefslogtreecommitdiff
path: root/website/usageExamples/BuilderExample_post.jpage
diff options
context:
space:
mode:
Diffstat (limited to 'website/usageExamples/BuilderExample_post.jpage')
-rw-r--r--website/usageExamples/BuilderExample_post.jpage18
1 files changed, 15 insertions, 3 deletions
diff --git a/website/usageExamples/BuilderExample_post.jpage b/website/usageExamples/BuilderExample_post.jpage
index 54b064d7..24d326b3 100644
--- a/website/usageExamples/BuilderExample_post.jpage
+++ b/website/usageExamples/BuilderExample_post.jpage
@@ -1,6 +1,7 @@
import java.util.Set;
public class BuilderExample {
+ private long created;
private String name;
private int age;
private Set<String> occupations;
@@ -11,11 +12,17 @@ public class BuilderExample {
this.occupations = occupations;
}
+ private static long $default$created() {
+ return System.currentTimeMillis();
+ }
+
public static BuilderExampleBuilder builder() {
return new BuilderExampleBuilder();
}
public static class BuilderExampleBuilder {
+ private long created;
+ private boolean created$set;
private String name;
private int age;
private java.util.ArrayList<String> occupations;
@@ -23,6 +30,12 @@ public class BuilderExample {
BuilderExampleBuilder() {
}
+ public BuilderExampleBuilder created(long created) {
+ this.created = created;
+ this.created$set = true;
+ return this;
+ }
+
public BuilderExampleBuilder name(String name) {
this.name = name;
return this;
@@ -61,14 +74,13 @@ public class BuilderExample {
public BuilderExample build() {
// complicated switch statement to produce a compact properly sized immutable set omitted.
- // go to https://projectlombok.org/features/Singular-snippet.html to see it.
Set<String> occupations = ...;
- return new BuilderExample(name, age, occupations);
+ return new BuilderExample(created$set ? created : BuilderExample.$default$created(), name, age, occupations);
}
@java.lang.Override
public String toString() {
- return "BuilderExample.BuilderExampleBuilder(name = " + this.name + ", age = " + this.age + ", occupations = " + this.occupations + ")";
+ return "BuilderExample.BuilderExampleBuilder(created = " + this.created + ", name = " + this.name + ", age = " + this.age + ", occupations = " + this.occupations + ")";
}
}
} \ No newline at end of file