aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/experimental/BuilderExample_post.jpage
blob: 624b236b20c20b3af27fdafb7fb97c698db777e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class BuilderExample {
	private String name;
	private int age;
	
	BuilderExample(String name, int age) {
		this.name = name;
		this.age = age;
	}
	
	public static BuilderExampleBuilder builder() {
		return new BuilderExampleBuilder();
	}
	
	public static class BuilderExampleBuilder {
		private String name;
		private int age;
		
		BuilderExampleBuilder() {
		}
		
		public BuilderExampleBuilder name(String name) {
			this.name = name;
			return this;
		}
		
		public BuilderExampleBuilder age(int age) {
			this.age = age;
			return this;
		}
		
		public BuilderExample build() {
			return new BuilderExample(name, age);
		}
		
		@java.lang.Override
		public String toString() {
			return "BuilderExample.BuilderExampleBuilder(name = " + this.name + ", age = " + this.age + ")";
		}
	}
}