-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHuman.java
More file actions
129 lines (109 loc) · 3.55 KB
/
Human.java
File metadata and controls
129 lines (109 loc) · 3.55 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package creation.builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.util.Date;
@Getter
public class Human {
private final String name;
private final String lastName;
private final int age;
private final String height;
private final String weight;
private final String eyesColor;
private final String hairColor;
private final String birthPlace;
private final Date birthDate;
private final int numberOfSibling;
private final boolean married;
private Human(HumanBuilder builder) {
this.name = builder.name;
this.lastName = builder.lastName;
this.age = builder.age;
this.height = builder.height;
this.weight = builder.weight;
this.eyesColor = builder.eyesColor;
this.hairColor = builder.hairColor;
this.birthPlace = builder.birthPlace;
this.birthDate = builder.birthDate;
this.numberOfSibling = builder.numberOfSibling;
this.married = builder.married;
}
@NoArgsConstructor
public static class HumanBuilder {
private String name;
private String lastName;
private int age;
private String height;
private String weight;
private String eyesColor;
private String hairColor;
private String birthPlace;
private Date birthDate;
private int numberOfSibling;
private boolean married;
public HumanBuilder withName(String name) {
this.name = name;
return this;
}
public HumanBuilder withLastName(String lastName) {
this.lastName = lastName;
return this;
}
public HumanBuilder withAge(int age) {
this.age = age;
return this;
}
public HumanBuilder withHeight(String height) {
this.height = height;
return this;
}
public HumanBuilder withWeight(String weight) {
this.weight = weight;
return this;
}
public HumanBuilder withEyesColor(String eyesColor) {
this.eyesColor = eyesColor;
return this;
}
public HumanBuilder withHairColor(String hairColor) {
this.hairColor = hairColor;
return this;
}
public HumanBuilder withBirthPlace(String birthPlace) {
this.birthPlace = birthPlace;
return this;
}
public HumanBuilder withBirthDate(Date birthDate) {
this.birthDate = birthDate;
return this;
}
public HumanBuilder withNumberOfSibling(int numberOfSibling) {
this.numberOfSibling = numberOfSibling;
return this;
}
public HumanBuilder isMarried(boolean married) {
this.married = married;
return this;
}
public Human build() {
Human human = new Human(this);
return human;
}
}
@Override
public String toString() {
return "Human{" +
"name='" + name + '\'' +
", lastName='" + lastName + '\'' +
", age=" + age +
", height='" + height + '\'' +
", weight='" + weight + '\'' +
", eyesColor='" + eyesColor + '\'' +
", hairColor='" + hairColor + '\'' +
", birthPlace='" + birthPlace + '\'' +
", birthDate=" + birthDate +
", numberOfSibling=" + numberOfSibling +
", married=" + married +
'}';
}
}