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 package com.ivata.mask.web.demo.product;
58 import java.math.BigDecimal;
59
60 import org.apache.log4j.Logger;
61
62 import com.ivata.mask.web.demo.valueobject.DemoValueObject;
63 /***
64 * <p>
65 * Represents a single product which can be ordered.
66 * </p>
67 *
68 * @author Colin MacLeod
69 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
70 * @since ivata masks 0.1 (2004-05-09)
71 * @version $Revision: 1.6 $
72 */
73 public final class ProductDO extends DemoValueObject {
74 /***
75 * Refer to {@link Logger}.
76 */
77 private static Logger log = Logger.getLogger(ProductDO.class);
78
79 /***
80 * <p>
81 * Full text description of the product.
82 * </p>
83 */
84 private String description;
85 /***
86 * <p>
87 * Name of the product. Clear text name, should be unique, though this is
88 * not enforced.
89 * </p>
90 */
91 private String name;
92 /***
93 * <p>
94 * Cost of each item of this product.
95 * </p>
96 */
97 private BigDecimal price;
98 /***
99 * <p>
100 * Construct a new product instance with no id.
101 * </p>
102 */
103 public ProductDO() {
104 super();
105 }
106 /***
107 * <p>
108 * Construct a new product instance with the given unique identifier.
109 * </p>
110 *
111 * @param id
112 * unique identifier of this product.
113 */
114 public ProductDO(final int id) {
115 super(id);
116 }
117 /***
118 * The product's description is a long text designed to make you desperate
119 * to own one immediately.
120 *
121 * @return long text designed to make you drool.
122 */
123 public String getDescription() {
124 return description;
125 }
126
127 /***
128 * For products, the value displayed is always the product's name.
129 *
130 * @return just returns the product's name.
131 * @see com.ivata.mask.valueobject.ValueObject#getStringValue()
132 */
133 public String getDisplayValue() {
134 return name;
135 }
136 /***
137 * The name of a product is unique among products - that short text which
138 * uniquely identifies it.
139 *
140 * @return unique name of this product.
141 */
142 public String getName() {
143 return name;
144 }
145 /***
146 * What price quality? This is the cost of a single unit of the product.
147 *
148 * @return cost of a single unit of the product.
149 */
150 public BigDecimal getPrice() {
151 return price;
152 }
153 /***
154 * The product's description is a long text designed to make you desperate
155 * to own one immediately.
156 *
157 * @param descriptionParam long text designed to make you drool.
158 */
159 public void setDescription(final String descriptionParam) {
160 if (log.isDebugEnabled()) {
161 log.debug("Set description was '"
162 + description
163 + "', now '"
164 + descriptionParam
165 + "'");
166 }
167 description = descriptionParam;
168 }
169 /***
170 * The name of a product is unique among products - that short text which
171 * uniquely identifies it.
172 *
173 * @param nameParam unique name of this product.
174 */
175 public void setName(final String nameParam) {
176 if (log.isDebugEnabled()) {
177 log.debug("Set name was '"
178 + name
179 + "', now '"
180 + nameParam
181 + "'");
182 }
183 name = nameParam;
184 }
185 /***
186 * Set the cost of one unit of this product.
187 *
188 * @param priceParam cost of a single unit of this product.
189 */
190 public void setPrice(final BigDecimal priceParam) {
191 if (log.isDebugEnabled()) {
192 log.debug("Set price was '"
193 + price
194 + "', now '"
195 + priceParam
196 + "'");
197 }
198 if ((price != null)
199 && (priceParam == null)) {
200 throw new NullPointerException();
201 }
202 price = priceParam;
203 }
204 }
205