1 /*
2 * Copyright (c) 2002-2025, City of Paris
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice
10 * and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice
13 * and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * License 1.0
33 */
34 /*
35 * To change this template, choose Tools | Templates
36 * and open the template in the editor.
37 */
38 package fr.paris.lutece.util.beanvalidation;
39
40 import org.hibernate.validator.constraints.Email;
41 import org.hibernate.validator.constraints.NotEmpty;
42 import org.hibernate.validator.constraints.URL;
43
44 import java.math.BigDecimal;
45 import java.util.Date;
46
47 import javax.validation.constraints.DecimalMax;
48 import javax.validation.constraints.DecimalMin;
49 import javax.validation.constraints.Digits;
50 import javax.validation.constraints.Future;
51 import javax.validation.constraints.Min;
52 import javax.validation.constraints.Past;
53 import javax.validation.constraints.Pattern;
54 import javax.validation.constraints.Size;
55
56 /**
57 *
58 * @author pierre
59 */
60 public class BeanDefaultMessages implements Bean
61 {
62 // Variables declarations
63 private int _nIdObject;
64 @NotEmpty( )
65 @Pattern( regexp = "[a-z-A-Z]" )
66 @Size( max = 5 )
67 private String _strName;
68 @Size( min = 10 )
69 private String _strDescription;
70 @Min( value = 5 )
71 private int _nAge;
72 @Email( )
73 private String _strEmail;
74 @Past
75 private Date _dateBirth;
76 @Future
77 private Date _dateEndOfWorld;
78 @DecimalMin( value = "1500.0" )
79 private BigDecimal _salary;
80 @DecimalMax( value = "100.0" )
81 private BigDecimal _percent;
82 @Digits( integer = 15, fraction = 2 )
83 private String _strCurrency;
84 @URL( )
85 private String _strUrl;
86
87 /**
88 * Returns the IdObject
89 *
90 * @return The IdObject
91 */
92 @Override
93 public int getIdObject( )
94 {
95 return _nIdObject;
96 }
97
98 /**
99 * Sets the IdObject
100 *
101 * @param nIdObject
102 * The IdObject
103 */
104 @Override
105 public void setIdObject( int nIdObject )
106 {
107 _nIdObject = nIdObject;
108 }
109
110 /**
111 * Returns the Name
112 *
113 * @return The Name
114 */
115 @Override
116 public String getName( )
117 {
118 return _strName;
119 }
120
121 /**
122 * Sets the Name
123 *
124 * @param strName
125 * The Name
126 */
127 @Override
128 public void setName( String strName )
129 {
130 _strName = strName;
131 }
132
133 /**
134 * Returns the Description
135 *
136 * @return The Description
137 */
138 @Override
139 public String getDescription( )
140 {
141 return _strDescription;
142 }
143
144 /**
145 * Sets the Description
146 *
147 * @param strDescription
148 * The Description
149 */
150 @Override
151 public void setDescription( String strDescription )
152 {
153 _strDescription = strDescription;
154 }
155
156 /**
157 * Returns the Age
158 *
159 * @return The Age
160 */
161 @Override
162 public int getAge( )
163 {
164 return _nAge;
165 }
166
167 /**
168 * Sets the Age
169 *
170 * @param nAge
171 * The Age
172 */
173 @Override
174 public void setAge( int nAge )
175 {
176 _nAge = nAge;
177 }
178
179 /**
180 * Returns the Email
181 *
182 * @return The Email
183 */
184 @Override
185 public String getEmail( )
186 {
187 return _strEmail;
188 }
189
190 /**
191 * Sets the Email
192 *
193 * @param strEmail
194 * The Email
195 */
196 @Override
197 public void setEmail( String strEmail )
198 {
199 _strEmail = strEmail;
200 }
201
202 /**
203 * @return the _dateBirth
204 */
205 @Override
206 public Date getDateBirth( )
207 {
208 return _dateBirth;
209 }
210
211 /**
212 * @param dateBirth
213 * the _dateBirth to set
214 */
215 @Override
216 public void setDateBirth( Date dateBirth )
217 {
218 _dateBirth = dateBirth;
219 }
220
221 /**
222 * @return the _dateEndOfWorld
223 */
224 @Override
225 public Date getDateEndOfWorld( )
226 {
227 return _dateEndOfWorld;
228 }
229
230 /**
231 * @param dateEndOfWorld
232 * the _dateEndOfWorld to set
233 */
234 @Override
235 public void setDateEndOfWorld( Date dateEndOfWorld )
236 {
237 _dateEndOfWorld = dateEndOfWorld;
238 }
239
240 /**
241 * @return the _salary
242 */
243 @Override
244 public BigDecimal getSalary( )
245 {
246 return _salary;
247 }
248
249 /**
250 * @param salary
251 * the _salary to set
252 */
253 @Override
254 public void setSalary( BigDecimal salary )
255 {
256 _salary = salary;
257 }
258
259 /**
260 * @return the _percent
261 */
262 @Override
263 public BigDecimal getPercent( )
264 {
265 return _percent;
266 }
267
268 /**
269 * @param percent
270 * the _percent to set
271 */
272 @Override
273 public void setPercent( BigDecimal percent )
274 {
275 _percent = percent;
276 }
277
278 /**
279 * @return the _strCurrency
280 */
281 @Override
282 public String getCurrency( )
283 {
284 return _strCurrency;
285 }
286
287 /**
288 * @param strCurrency
289 * the _strCurrency to set
290 */
291 @Override
292 public void setCurrency( String strCurrency )
293 {
294 _strCurrency = strCurrency;
295 }
296
297 /**
298 * @return the _strUrl
299 */
300 @Override
301 public String getUrl( )
302 {
303 return _strUrl;
304 }
305
306 /**
307 * @param strUrl
308 * the _strUrl to set
309 */
310 @Override
311 public void setUrl( String strUrl )
312 {
313 _strUrl = strUrl;
314 }
315 }