1
2
3
4 package org.company.thesandbox.domain;
5
6 import org.mod4j.runtime.validation.BusinessRuleValidationSupport;
7
8 import java.util.Collections;
9 import java.util.Set;
10 import java.util.HashSet;
11 import org.mod4j.runtime.validation.MinValueValidator;
12 import org.mod4j.runtime.validation.MaxValueValidator;
13 import org.mod4j.runtime.validation.MinLengthValidator;
14 import org.mod4j.runtime.validation.MaxLengthValidator;
15 import org.mod4j.runtime.validation.RegExpValidator;
16
17
18
19
20
21
22
23 @SuppressWarnings("serial")
24 public abstract class ProductImplBase implements java.io.Serializable {
25
26
27
28
29
30 protected BusinessRuleValidationSupport validation = new BusinessRuleValidationSupport(this);
31
32
33
34
35 private long id;
36
37 @SuppressWarnings("unused")
38 private int version = -1;
39
40
41
42
43
44 public Long getId() {
45 return this.id;
46 }
47
48
49
50
51 private String productNumnber;
52
53
54
55
56 private int price;
57
58 private Set<Record> record = new HashSet<Record>();
59
60 public Set<Record> getRecord() {
61 return this.record;
62 }
63
64
65
66
67
68
69 public void addToRecord(Record element) {
70 if (element == null) {
71 return;
72 }
73 if (this.record.contains(element)) {
74 return;
75 }
76 this.record.add(element);
77 if (element.getProduct() != null) {
78 element.getProduct().z_internalRemoveFromRecord(element);
79 }
80 element.z_internalSetProduct((Product) this);
81
82 }
83
84 public void removeFromRecord(Record element) {
85 if (element == null) {
86 return;
87 }
88 this.record.remove(element);
89 element.z_internalRemoveProduct((Product) this);
90
91 }
92
93
94
95
96
97
98
99 public void z_internalAddToRecord(Record element) {
100 this.record.add(element);
101 }
102
103
104
105
106
107
108
109 public void z_internalRemoveFromRecord(Record element) {
110 this.record.remove(element);
111 }
112
113
114
115
116 protected ProductImplBase() {
117
118 }
119
120
121
122
123
124
125
126
127
128 public ProductImplBase(String productNumnber, int price) {
129
130 this.productNumnber = productNumnber;
131 this.price = price;
132
133 validation.validate();
134 }
135
136
137
138
139
140 public String getProductNumnber() {
141 return this.productNumnber;
142 }
143
144
145
146
147
148 public int getPrice() {
149 return this.price;
150 }
151
152
153
154
155
156 public void setProductNumnber(final String productNumnber) {
157 this.productNumnber = productNumnber;
158 validation.validate();
159 }
160
161
162
163
164
165 public void setPrice(final int price) {
166 this.price = price;
167 validation.validate();
168 }
169
170
171
172
173
174
175
176
177 public void activateValidation(boolean value) {
178
179 this.validation.setActive(value);
180 if (value) {
181 validation.validate();
182 }
183 }
184
185 }