001/*
002 *   Copyright (C) Christian Schulte, 2005-206
003 *   All rights reserved.
004 *
005 *   Redistribution and use in source and binary forms, with or without
006 *   modification, are permitted provided that the following conditions
007 *   are met:
008 *
009 *     o Redistributions of source code must retain the above copyright
010 *       notice, this list of conditions and the following disclaimer.
011 *
012 *     o Redistributions in binary form must reproduce the above copyright
013 *       notice, this list of conditions and the following disclaimer in
014 *       the documentation and/or other materials provided with the
015 *       distribution.
016 *
017 *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
018 *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
019 *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
020 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
021 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
022 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
023 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
024 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
026 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027 *
028 *   $JOMC: TestModelValidator.java 4654 2012-11-15 22:28:26Z schulte $
029 *
030 */
031package org.jomc.modlet.test.support;
032
033import java.net.URL;
034import org.jomc.modlet.Model;
035import org.jomc.modlet.ModelContext;
036import org.jomc.modlet.ModelException;
037import org.jomc.modlet.ModelValidationReport;
038import org.jomc.modlet.ModelValidator;
039
040/**
041 * {@code ModelValidator} test implementation.
042 *
043 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
044 * @version $JOMC: TestModelValidator.java 4654 2012-11-15 22:28:26Z schulte $
045 */
046public final class TestModelValidator implements ModelValidator
047{
048
049    private boolean booleanProperty;
050
051    private boolean boxedBooleanProperty;
052
053    private Boolean unboxedBooleanProperty;
054
055    private char characterProperty;
056
057    private char boxedCharacterProperty;
058
059    private Character unboxedCharacterProperty;
060
061    private byte byteProperty;
062
063    private byte boxedByteProperty;
064
065    private Byte unboxedByteProperty;
066
067    private short shortProperty;
068
069    private short boxedShortProperty;
070
071    private Short unboxedShortProperty;
072
073    private int intProperty;
074
075    private int boxedIntProperty;
076
077    private Integer unboxedIntProperty;
078
079    private long longProperty;
080
081    private long boxedLongProperty;
082
083    private Long unboxedLongProperty;
084
085    private float floatProperty;
086
087    private float boxedFloatProperty;
088
089    private Float unboxedFloatProperty;
090
091    private double doubleProperty;
092
093    private double boxedDoubleProperty;
094
095    private Double unboxedDoubleProperty;
096
097    private String stringProperty;
098
099    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}