View Javadoc
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  package fr.paris.lutece.util.beanvalidation;
35  
36  import org.hibernate.validator.constraints.Email;
37  import org.hibernate.validator.constraints.NotEmpty;
38  import org.hibernate.validator.constraints.URL;
39  
40  import java.math.BigDecimal;
41  import java.util.Date;
42  
43  import javax.validation.constraints.DecimalMax;
44  import javax.validation.constraints.DecimalMin;
45  import javax.validation.constraints.Digits;
46  import javax.validation.constraints.Future;
47  import javax.validation.constraints.Min;
48  import javax.validation.constraints.Past;
49  import javax.validation.constraints.Pattern;
50  import javax.validation.constraints.Size;
51  
52  /**
53   * BeanLuteceMessages class for bean validation tests
54   */
55  public class BeanLuteceMessages implements Bean
56  {
57      // Variables declarations
58      private int _nIdObject;
59      @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" )
60      @Pattern( regexp = "[a-z-A-Z]", message = "#i18n{portal.validation.message.pattern}" )
61      @Size( max = 5, message = "#i18n{portal.validation.message.sizeMax}" )
62      private String _strName;
63      @Size( min = 10, max = 50, message = "#i18n{portal.validation.message.size}" )
64      private String _strDescription;
65      @Min( value = 5, message = "#i18n{portal.validation.message.min}" )
66      private int _nAge;
67      @Email( message = "#i18n{portal.validation.message.email}" )
68      private String _strEmail;
69      @Past( message = "#i18n{portal.validation.message.past}" )
70      private Date _dateBirth;
71      @Future( message = "#i18n{portal.validation.message.future}" )
72      private Date _dateEndOfWorld;
73      @DecimalMin( value = "1500.0", message = "#i18n{portal.validation.message.decimalMin}" )
74      private BigDecimal _salary;
75      @DecimalMax( value = "100.0", message = "#i18n{portal.validation.message.decimalMax}" )
76      private BigDecimal _percent;
77      @Digits( integer = 15, fraction = 2, message = "#i18n{portal.validation.message.digits}" )
78      private String _strCurrency;
79      @URL( message = "#i18n{portal.validation.message.url}" )
80      private String _strUrl;
81  
82      /**
83       * Returns the IdObject
84       *
85       * @return The IdObject
86       */
87      @Override
88      public int getIdObject( )
89      {
90          return _nIdObject;
91      }
92  
93      /**
94       * Sets the IdObject
95       *
96       * @param nIdObject
97       *            The IdObject
98       */
99      @Override
100     public void setIdObject( int nIdObject )
101     {
102         _nIdObject = nIdObject;
103     }
104 
105     /**
106      * Returns the Name
107      *
108      * @return The Name
109      */
110     @Override
111     public String getName( )
112     {
113         return _strName;
114     }
115 
116     /**
117      * Sets the Name
118      *
119      * @param strName
120      *            The Name
121      */
122     @Override
123     public void setName( String strName )
124     {
125         _strName = strName;
126     }
127 
128     /**
129      * Returns the Description
130      *
131      * @return The Description
132      */
133     @Override
134     public String getDescription( )
135     {
136         return _strDescription;
137     }
138 
139     /**
140      * Sets the Description
141      *
142      * @param strDescription
143      *            The Description
144      */
145     @Override
146     public void setDescription( String strDescription )
147     {
148         _strDescription = strDescription;
149     }
150 
151     /**
152      * Returns the Age
153      *
154      * @return The Age
155      */
156     @Override
157     public int getAge( )
158     {
159         return _nAge;
160     }
161 
162     /**
163      * Sets the Age
164      *
165      * @param nAge
166      *            The Age
167      */
168     @Override
169     public void setAge( int nAge )
170     {
171         _nAge = nAge;
172     }
173 
174     /**
175      * Returns the Email
176      *
177      * @return The Email
178      */
179     @Override
180     public String getEmail( )
181     {
182         return _strEmail;
183     }
184 
185     /**
186      * Sets the Email
187      *
188      * @param strEmail
189      *            The Email
190      */
191     @Override
192     public void setEmail( String strEmail )
193     {
194         _strEmail = strEmail;
195     }
196 
197     /**
198      * @return the _dateBirth
199      */
200     @Override
201     public Date getDateBirth( )
202     {
203         return _dateBirth;
204     }
205 
206     /**
207      * @param dateBirth
208      *            the _dateBirth to set
209      */
210     @Override
211     public void setDateBirth( Date dateBirth )
212     {
213         _dateBirth = dateBirth;
214     }
215 
216     /**
217      * @return the _dateEndOfWorld
218      */
219     @Override
220     public Date getDateEndOfWorld( )
221     {
222         return _dateEndOfWorld;
223     }
224 
225     /**
226      * @param dateEndOfWorld
227      *            the _dateEndOfWorld to set
228      */
229     @Override
230     public void setDateEndOfWorld( Date dateEndOfWorld )
231     {
232         _dateEndOfWorld = dateEndOfWorld;
233     }
234 
235     /**
236      * @return the _salary
237      */
238     @Override
239     public BigDecimal getSalary( )
240     {
241         return _salary;
242     }
243 
244     /**
245      * @param salary
246      *            the _salary to set
247      */
248     @Override
249     public void setSalary( BigDecimal salary )
250     {
251         _salary = salary;
252     }
253 
254     /**
255      * @return the _percent
256      */
257     @Override
258     public BigDecimal getPercent( )
259     {
260         return _percent;
261     }
262 
263     /**
264      * @param percent
265      *            the _percent to set
266      */
267     @Override
268     public void setPercent( BigDecimal percent )
269     {
270         _percent = percent;
271     }
272 
273     /**
274      * @return the _strCurrency
275      */
276     @Override
277     public String getCurrency( )
278     {
279         return _strCurrency;
280     }
281 
282     /**
283      * @param strCurrency
284      *            the _strCurrency to set
285      */
286     @Override
287     public void setCurrency( String strCurrency )
288     {
289         _strCurrency = strCurrency;
290     }
291 
292     /**
293      * @return the _strUrl
294      */
295     @Override
296     public String getUrl( )
297     {
298         return _strUrl;
299     }
300 
301     /**
302      * @param strUrl
303      *            the _strUrl to set
304      */
305     @Override
306     public void setUrl( String strUrl )
307     {
308         _strUrl = strUrl;
309     }
310 }