1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sourceforge.domian.test.domain;
17
18
19 import java.io.File;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.List;
24 import java.util.Set;
25
26 import net.sourceforge.domian.entity.AbstractRandomIntegerEntity;
27
28
29 public class Customer extends AbstractRandomIntegerEntity {
30
31 public enum Gender {
32 MALE, FEMALE
33 }
34
35 protected Long customerId;
36 protected Date membershipDate;
37 protected String name;
38 protected Address address;
39 protected Gender gender;
40 protected Date birthDate;
41 protected Boolean foreign = Boolean.FALSE;
42 protected List<Order> orders = new ArrayList<Order>();
43 protected Customer enlistedBy;
44 protected Set<Customer> enlistedCustomers;
45
46
47 protected Long fieldWithNoGetter_1;
48 protected File fieldWithNoGetter_2;
49 protected Collection<Customer> fieldWithNoGetter_3;
50
51
52 public Customer() {}
53
54 public Customer(final Long customerId, final Date membershipDate) {
55 this.customerId = customerId;
56 this.membershipDate = membershipDate;
57 }
58
59 public Customer(final Long customerId, final List<Order> orders, final Date membershipDate) {
60 this.customerId = customerId;
61 this.orders = orders;
62 this.membershipDate = membershipDate;
63 }
64
65 public static Customer createInstance(final Long customerId, final Date membershipDate) {
66 return new Customer(customerId, membershipDate);
67 }
68
69 public static Customer createCustomer(final Long customerId, final List<Order> orders, final Date membershipDate) {
70 return new Customer(customerId, orders, membershipDate);
71 }
72
73 public Long getCustomerId() {
74 return customerId;
75 }
76
77
78 public void setCustomerId(final Long customerId) {
79 this.customerId = customerId;
80 }
81
82 public Date getMembershipDate() {
83 return membershipDate;
84 }
85
86 public void setMembershipDate(final Date membershipDate) {
87 this.membershipDate = membershipDate;
88 }
89
90
91 @SuppressWarnings("unchecked")
92 public <T extends Customer> T membershipDate(final Date membershipDate) {
93 this.membershipDate = membershipDate;
94 return (T) this;
95 }
96
97 public String getName() {
98 return name;
99 }
100
101 public void setName(final String name) {
102 this.name = name;
103 }
104
105
106 @SuppressWarnings("unchecked")
107 public <T extends Customer> T name(final String name) {
108 this.name = name;
109 return (T) this;
110 }
111
112 public Address getAddress() {
113 return address;
114 }
115
116 public void setAddress(final Address address) {
117 this.address = address;
118 }
119
120
121 @SuppressWarnings("unchecked")
122 public <T extends Customer> T address(final String addressline1) {
123 this.address = new Address(addressline1, null, null, null, null, null);
124 return (T) this;
125 }
126
127
128 @SuppressWarnings("unchecked")
129 public <T extends Customer> T address(final Address address) {
130 this.address = address;
131 return (T) this;
132 }
133
134 public Gender getGender() {
135 return gender;
136 }
137
138 public void setGender(final Gender gender) {
139 this.gender = gender;
140 }
141
142
143 @SuppressWarnings("unchecked")
144 public <T extends Customer> T gender(final Gender gender) {
145 this.gender = gender;
146 return (T) this;
147 }
148
149 public Date getBirthDate() {
150 return birthDate;
151 }
152
153 public void setBirthDate(final Date birthDate) {
154 this.birthDate = birthDate;
155 }
156
157
158 @SuppressWarnings("unchecked")
159 public <T extends Customer> T birthDate(final Date birthDate) {
160 this.birthDate = birthDate;
161 return (T) this;
162 }
163
164 public Boolean getForeign() {
165 return this.foreign;
166 }
167
168 public void setForeign(final Boolean foreign) {
169 this.foreign = foreign;
170 }
171
172
173 @SuppressWarnings("unchecked")
174 public <T extends Customer> T foreign(final Boolean foreign) {
175 this.foreign = foreign;
176 return (T) this;
177 }
178
179 public List<Order> getOrders() {
180 return orders;
181 }
182
183
184
185
186
187
188
189 public Customer getEnlistedBy() {
190 return enlistedBy;
191 }
192
193 public void setEnlistedBy(final Customer enlistedBy) {
194 this.enlistedBy = enlistedBy;
195 }
196
197 public Set<Customer> getEnlistedCustomers() {
198 return enlistedCustomers;
199 }
200
201 public void setEnlistedCustomers(final Set<Customer> enlistedCustomers) {
202 this.enlistedCustomers = enlistedCustomers;
203 }
204
205 public void setFieldWithNoGetter_1(Long fieldWithNoGetter_1) {
206 this.fieldWithNoGetter_1 = fieldWithNoGetter_1;
207 }
208
209 public void setFieldWithNoGetter_2(File fieldWithNoGetter_2) {
210 this.fieldWithNoGetter_2 = fieldWithNoGetter_2;
211 }
212
213 public void setFieldWithNoGetter_3(Collection<Customer> fieldWithNoGetter_3) {
214 this.fieldWithNoGetter_3 = fieldWithNoGetter_3;
215 }
216
217 public void addOrder(final Order order) {
218 order.setCustomer(this);
219 orders.add(order);
220 }
221
222 public void clearOrders() {
223
224 for (final Order order : this.orders) {
225 order.setCustomer(null);
226 }
227 this.orders.clear();
228 }
229 }