View Javadoc

1   /*
2    *   Copyright (C) Christian Schulte, 2005-206
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    *     o Redistributions of source code must retain the above copyright
10   *       notice, this list of conditions and the following disclaimer.
11   *
12   *     o Redistributions in binary form must reproduce the above copyright
13   *       notice, this list of conditions and the following disclaimer in
14   *       the documentation and/or other materials provided with the
15   *       distribution.
16   *
17   *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18   *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19   *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20   *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21   *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22   *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23   *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24   *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26   *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27   *
28   *   $JOMC: TestModelValidator.java 4654 2012-11-15 22:28:26Z schulte $
29   *
30   */
31  package org.jomc.modlet.test.support;
32  
33  import java.net.URL;
34  import org.jomc.modlet.Model;
35  import org.jomc.modlet.ModelContext;
36  import org.jomc.modlet.ModelException;
37  import org.jomc.modlet.ModelValidationReport;
38  import org.jomc.modlet.ModelValidator;
39  
40  /**
41   * {@code ModelValidator} test implementation.
42   *
43   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
44   * @version $JOMC: TestModelValidator.java 4654 2012-11-15 22:28:26Z schulte $
45   */
46  public final class TestModelValidator implements ModelValidator
47  {
48  
49      private boolean booleanProperty;
50  
51      private boolean boxedBooleanProperty;
52  
53      private Boolean unboxedBooleanProperty;
54  
55      private char characterProperty;
56  
57      private char boxedCharacterProperty;
58  
59      private Character unboxedCharacterProperty;
60  
61      private byte byteProperty;
62  
63      private byte boxedByteProperty;
64  
65      private Byte unboxedByteProperty;
66  
67      private short shortProperty;
68  
69      private short boxedShortProperty;
70  
71      private Short unboxedShortProperty;
72  
73      private int intProperty;
74  
75      private int boxedIntProperty;
76  
77      private Integer unboxedIntProperty;
78  
79      private long longProperty;
80  
81      private long boxedLongProperty;
82  
83      private Long unboxedLongProperty;
84  
85      private float floatProperty;
86  
87      private float boxedFloatProperty;
88  
89      private Float unboxedFloatProperty;
90  
91      private double doubleProperty;
92  
93      private double boxedDoubleProperty;
94  
95      private Double unboxedDoubleProperty;
96  
97      private String stringProperty;
98  
99      private URL urlProperty;
100 
101     private Thread.State enumProperty;
102 
103     private Object objectProperty;
104 
105     private String stringPropertyWithoutSetter;
106 
107     private String stringPropertyWithoutGetter;
108 
109     private Math unsupportedPropertyType;
110 
111     private InstantiationExceptionPropertyType instantiationExceptionProperty;
112 
113     private InvocationTargetExceptionPropertyType invocationTargetExceptionProperty;
114 
115     public TestModelValidator()
116     {
117         super();
118     }
119 
120     public ModelValidationReport validateModel( final ModelContext context, final Model model ) throws ModelException
121     {
122         if ( context == null )
123         {
124             throw new NullPointerException( "context" );
125         }
126         if ( model == null )
127         {
128             throw new NullPointerException( "model" );
129         }
130 
131         context.setAttribute( TestModelValidator.class.getName(), this );
132         return new ModelValidationReport();
133     }
134 
135     public boolean isBooleanProperty()
136     {
137         return this.booleanProperty;
138     }
139 
140     public void setBooleanProperty( final boolean value )
141     {
142         this.booleanProperty = value;
143     }
144 
145     public Boolean isBoxedBooleanProperty()
146     {
147         return this.boxedBooleanProperty;
148     }
149 
150     public void setBoxedBooleanProperty( final boolean value )
151     {
152         this.boxedBooleanProperty = value;
153     }
154 
155     public boolean isUnboxedBooleanProperty()
156     {
157         return this.unboxedBooleanProperty ? true : false;
158     }
159 
160     public void setUnboxedBooleanProperty( final Boolean value )
161     {
162         this.unboxedBooleanProperty = value;
163     }
164 
165     public char getCharacterProperty()
166     {
167         return this.characterProperty;
168     }
169 
170     public void setCharacterProperty( final char value )
171     {
172         this.characterProperty = value;
173     }
174 
175     public Character getBoxedCharacterProperty()
176     {
177         return this.boxedCharacterProperty;
178     }
179 
180     public void setBoxedCharacterProperty( final char value )
181     {
182         this.boxedCharacterProperty = value;
183     }
184 
185     public char getUnboxedCharacterProperty()
186     {
187         return this.unboxedCharacterProperty;
188     }
189 
190     public void setUnboxedCharacterProperty( final Character value )
191     {
192         this.unboxedCharacterProperty = value;
193     }
194 
195     public byte getByteProperty()
196     {
197         return this.byteProperty;
198     }
199 
200     public void setByteProperty( final byte value )
201     {
202         this.byteProperty = value;
203     }
204 
205     public Byte getBoxedByteProperty()
206     {
207         return this.boxedByteProperty;
208     }
209 
210     public void setBoxedByteProperty( final byte value )
211     {
212         this.boxedByteProperty = value;
213     }
214 
215     public byte getUnboxedByteProperty()
216     {
217         return this.unboxedByteProperty;
218     }
219 
220     public void setUnboxedByteProperty( final Byte value )
221     {
222         this.unboxedByteProperty = value;
223     }
224 
225     public short getShortProperty()
226     {
227         return this.shortProperty;
228     }
229 
230     public void setShortProperty( final short value )
231     {
232         this.shortProperty = value;
233     }
234 
235     public Short getBoxedShortProperty()
236     {
237         return this.boxedShortProperty;
238     }
239 
240     public void setBoxedShortProperty( final short value )
241     {
242         this.boxedShortProperty = value;
243     }
244 
245     public short getUnboxedShortProperty()
246     {
247         return this.unboxedShortProperty;
248     }
249 
250     public void setUnboxedShortProperty( final Short value )
251     {
252         this.unboxedShortProperty = value;
253     }
254 
255     public int getIntProperty()
256     {
257         return this.intProperty;
258     }
259 
260     public void setIntProperty( final int value )
261     {
262         this.intProperty = value;
263     }
264 
265     public Integer getBoxedIntProperty()
266     {
267         return this.boxedIntProperty;
268     }
269 
270     public void setBoxedIntProperty( final int value )
271     {
272         this.boxedIntProperty = value;
273     }
274 
275     public int getUnboxedIntProperty()
276     {
277         return this.unboxedIntProperty;
278     }
279 
280     public void setUnboxedIntProperty( final Integer value )
281     {
282         this.unboxedIntProperty = value;
283     }
284 
285     public long getLongProperty()
286     {
287         return this.longProperty;
288     }
289 
290     public void setLongProperty( final long value )
291     {
292         this.longProperty = value;
293     }
294 
295     public Long getBoxedLongProperty()
296     {
297         return this.boxedLongProperty;
298     }
299 
300     public void setBoxedLongProperty( final long value )
301     {
302         this.boxedLongProperty = value;
303     }
304 
305     public long getUnboxedLongProperty()
306     {
307         return this.unboxedLongProperty;
308     }
309 
310     public void setUnboxedLongProperty( final Long value )
311     {
312         this.unboxedLongProperty = value;
313     }
314 
315     public float getFloatProperty()
316     {
317         return this.floatProperty;
318     }
319 
320     public void setFloatProperty( final float value )
321     {
322         this.floatProperty = value;
323     }
324 
325     public Float getBoxedFloatProperty()
326     {
327         return this.boxedFloatProperty;
328     }
329 
330     public void setBoxedFloatProperty( final float value )
331     {
332         this.boxedFloatProperty = value;
333     }
334 
335     public float getUnboxedFloatProperty()
336     {
337         return this.unboxedFloatProperty;
338     }
339 
340     public void setUnboxedFloatProperty( final Float value )
341     {
342         this.unboxedFloatProperty = value;
343     }
344 
345     public double getDoubleProperty()
346     {
347         return this.doubleProperty;
348     }
349 
350     public void setDoubleProperty( final double value )
351     {
352         this.doubleProperty = value;
353     }
354 
355     public Double getBoxedDoubleProperty()
356     {
357         return this.boxedDoubleProperty;
358     }
359 
360     public void setBoxedDoubleProperty( final double value )
361     {
362         this.boxedDoubleProperty = value;
363     }
364 
365     public double getUnboxedDoubleProperty()
366     {
367         return this.unboxedDoubleProperty;
368     }
369 
370     public void setUnboxedDoubleProperty( final Double value )
371     {
372         this.unboxedDoubleProperty = value;
373     }
374 
375     public String getStringProperty()
376     {
377         return this.stringProperty;
378     }
379 
380     public void setStringProperty( final String value )
381     {
382         this.stringProperty = value;
383     }
384 
385     public String getStringPropertyWithoutSetter()
386     {
387         return this.stringPropertyWithoutSetter;
388     }
389 
390     public void setStringPropertyWithoutGetter( final String value )
391     {
392         this.stringPropertyWithoutGetter = value;
393     }
394 
395     public URL getUrlProperty()
396     {
397         return this.urlProperty;
398     }
399 
400     public void setUrlProperty( final URL value )
401     {
402         this.urlProperty = value;
403     }
404 
405     public Thread.State getEnumProperty()
406     {
407         return this.enumProperty;
408     }
409 
410     public void setEnumProperty( final Thread.State value )
411     {
412         this.enumProperty = value;
413     }
414 
415     public Object getObjectProperty()
416     {
417         return this.objectProperty;
418     }
419 
420     public void setObjectProperty( final Object value )
421     {
422         this.objectProperty = value;
423     }
424 
425     public Math getUnsupportedPropertyType()
426     {
427         return this.unsupportedPropertyType;
428     }
429 
430     public void setUnsupportedPropertyType( final Math value )
431     {
432         this.unsupportedPropertyType = value;
433     }
434 
435     public InstantiationExceptionPropertyType getInstantiationExceptionProperty()
436     {
437         return this.instantiationExceptionProperty;
438     }
439 
440     public void setInstantiationExceptionProperty( final InstantiationExceptionPropertyType value )
441     {
442         this.instantiationExceptionProperty = value;
443     }
444 
445     public InvocationTargetExceptionPropertyType getInvocationTargetExceptionProperty()
446     {
447         return this.invocationTargetExceptionProperty;
448     }
449 
450     public void setInvocationTargetExceptionProperty( final InvocationTargetExceptionPropertyType value )
451     {
452         this.invocationTargetExceptionProperty = value;
453     }
454 
455 }