1
2
3
4
5 package org.company.thesandbox.domain;
6
7 import org.mod4j.runtime.validation.BusinessRuleValidationSupport;
8
9 import java.util.Collections;
10 import java.util.Set;
11 import java.util.HashSet;
12 import org.mod4j.runtime.validation.MinValueValidator;
13 import org.mod4j.runtime.validation.MaxValueValidator;
14 import org.mod4j.runtime.validation.MinLengthValidator;
15 import org.mod4j.runtime.validation.MaxLengthValidator;
16 import org.mod4j.runtime.validation.RegExpValidator;
17
18
19
20
21
22
23
24 @SuppressWarnings("serial")
25 public abstract class RecordImplBase implements java.io.Serializable {
26
27
28
29
30
31
32 protected BusinessRuleValidationSupport validation = new BusinessRuleValidationSupport(this);
33
34
35
36
37 private long id;
38
39 @SuppressWarnings("unused")
40 private int version = -1;
41
42
43
44
45
46 public Long getId() {
47 return this.id;
48 }
49
50
51
52
53 private String asin;
54
55
56
57
58 private String title = "Title unknown";
59
60
61
62
63 private int mediumCode = 111;
64
65
66
67
68 private float price;
69
70
71
72
73 private RecordType type = RecordType.CD;
74
75
76
77
78 private Product product;
79
80
81
82
83 public Product getProduct() {
84 return this.product;
85 }
86
87
88
89
90 public void setProduct(Product element) {
91 if (this.product != element) {
92
93 if (this.product != null) {
94 this.product.z_internalRemoveFromRecord((Record) this);
95 }
96
97 this.product = element;
98
99 if (element != null) {
100 element.z_internalAddToRecord((Record) this);
101 }
102
103 }
104 }
105
106
107
108
109
110
111
112 public void z_internalSetProduct(Product element) {
113 this.product = element;
114 }
115
116
117
118
119
120
121
122 public void z_internalRemoveProduct(Product element) {
123 this.product = null;
124 }
125
126
127
128
129 private Set<Artist> contributors = new HashSet<Artist>();
130
131
132
133
134 public Set<Artist> getContributors() {
135 return Collections.unmodifiableSet(this.contributors);
136 }
137
138
139
140
141 public void addToContributors(Artist element) {
142 this.contributors.add(element);
143 validation.validate();
144 }
145
146
147
148
149 public void removeFromContributors(Artist element) {
150 this.contributors.remove(element);
151 validation.validate();
152 }
153
154 private OrderLine orderLine;
155
156
157
158
159 public OrderLine getOrderLine() {
160 return this.orderLine;
161 }
162
163
164
165
166 public void setOrderLine(OrderLine element) {
167 if (this.orderLine != element) {
168
169 if (this.orderLine != null) {
170 this.orderLine.z_internalRemoverecord((Record) this);
171 }
172
173 this.orderLine = element;
174
175 if (element != null) {
176
177 element.setRecord((Record) this);
178 }
179
180 }
181 }
182
183
184
185
186
187
188
189
190 public void z_internalRemoveorderLine(final OrderLine element) {
191 this.orderLine = null;
192 }
193
194
195
196
197 protected RecordImplBase() {
198
199 }
200
201
202
203
204
205
206
207
208
209 public RecordImplBase(final String asin2, final float price2) {
210
211 this.asin = asin2;
212 this.price = price2;
213
214 validation.validate();
215 }
216
217
218
219
220
221 public String getAsin() {
222 return this.asin;
223 }
224
225
226
227
228
229 public String getTitle() {
230 return this.title;
231 }
232
233
234
235
236
237 public int getMediumCode() {
238 return this.mediumCode;
239 }
240
241
242
243
244
245 public float getPrice() {
246 return this.price;
247 }
248
249
250
251
252
253 public RecordType getType() {
254 return this.type;
255 }
256
257
258
259
260
261 public void setAsin(final String asin) {
262 this.asin = asin;
263 validation.validate();
264 }
265
266
267
268
269
270 public void setTitle(final String title) {
271 this.title = title;
272 validation.validate();
273 }
274
275
276
277
278
279 public void setMediumCode(final int mediumCode) {
280 this.mediumCode = mediumCode;
281 validation.validate();
282 }
283
284
285
286
287
288 public void setPrice(final float price) {
289 this.price = price;
290 validation.validate();
291 }
292
293
294
295
296
297 public void setType(final RecordType type) {
298 this.type = type;
299 validation.validate();
300 }
301
302
303
304
305
306
307
308
309 public void activateValidation(boolean value) {
310
311 this.validation.setActive(value);
312 if (value) {
313 validation.validate();
314 }
315 }
316
317 }