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: TestModelProcessor.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.ModelProcessor;
38  import org.jomc.modlet.test.TestComplexType;
39  import static org.junit.Assert.assertNotNull;
40  
41  /**
42   * {@code ModelProcessor} test implementation.
43   *
44   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
45   * @version $JOMC: TestModelProcessor.java 4654 2012-11-15 22:28:26Z schulte $
46   */
47  public final class TestModelProcessor implements ModelProcessor
48  {
49  
50      private boolean booleanProperty;
51  
52      private boolean boxedBooleanProperty;
53  
54      private Boolean unboxedBooleanProperty;
55  
56      private char characterProperty;
57  
58      private char boxedCharacterProperty;
59  
60      private Character unboxedCharacterProperty;
61  
62      private byte byteProperty;
63  
64      private byte boxedByteProperty;
65  
66      private Byte unboxedByteProperty;
67  
68      private short shortProperty;
69  
70      private short boxedShortProperty;
71  
72      private Short unboxedShortProperty;
73  
74      private int intProperty;
75  
76      private int boxedIntProperty;
77  
78      private Integer unboxedIntProperty;
79  
80      private long longProperty;
81  
82      private long boxedLongProperty;
83  
84      private Long unboxedLongProperty;
85  
86      private float floatProperty;
87  
88      private float boxedFloatProperty;
89  
90      private Float unboxedFloatProperty;
91  
92      private double doubleProperty;
93  
94      private double boxedDoubleProperty;
95  
96      private Double unboxedDoubleProperty;
97  
98      private String stringProperty;
99  
100     private URL urlProperty;
101 
102     private Thread.State enumProperty;
103 
104     private Object objectProperty;
105 
106     private String stringPropertyWithoutSetter;
107 
108     private String stringPropertyWithoutGetter;
109 
110     private Math unsupportedPropertyType;
111 
112     private InstantiationExceptionPropertyType instantiationExceptionProperty;
113 
114     private InvocationTargetExceptionPropertyType invocationTargetExceptionProperty;
115 
116     public TestModelProcessor()
117     {
118         super();
119     }
120 
121     public Model processModel( final ModelContext context, final Model model ) throws ModelException
122     {
123         if ( context == null )
124         {
125             throw new NullPointerException( "context" );
126         }
127         if ( model == null )
128         {
129             throw new NullPointerException( "model" );
130         }
131 
132         context.setAttribute( TestModelProcessor.class.getName(), this );
133 
134         final Model processed = model.clone();
135         final TestComplexType t = processed.getAnyObject( TestComplexType.class );
136         assertNotNull( t );
137 
138         t.getAny().add( new TestComplexType() );
139         return processed;
140     }
141 
142     public boolean isBooleanProperty()
143     {
144         return this.booleanProperty;
145     }
146 
147     public void setBooleanProperty( final boolean value )
148     {
149         this.booleanProperty = value;
150     }
151 
152     public Boolean isBoxedBooleanProperty()
153     {
154         return this.boxedBooleanProperty;
155     }
156 
157     public void setBoxedBooleanProperty( final boolean value )
158     {
159         this.boxedBooleanProperty = value;
160     }
161 
162     public boolean isUnboxedBooleanProperty()
163     {
164         return this.unboxedBooleanProperty ? true : false;
165     }
166 
167     public void setUnboxedBooleanProperty( final Boolean value )
168     {
169         this.unboxedBooleanProperty = value;
170     }
171 
172     public char getCharacterProperty()
173     {
174         return this.characterProperty;
175     }
176 
177     public void setCharacterProperty( final char value )
178     {
179         this.characterProperty = value;
180     }
181 
182     public Character getBoxedCharacterProperty()
183     {
184         return this.boxedCharacterProperty;
185     }
186 
187     public void setBoxedCharacterProperty( final char value )
188     {
189         this.boxedCharacterProperty = value;
190     }
191 
192     public char getUnboxedCharacterProperty()
193     {
194         return this.unboxedCharacterProperty;
195     }
196 
197     public void setUnboxedCharacterProperty( final Character value )
198     {
199         this.unboxedCharacterProperty = value;
200     }
201 
202     public byte getByteProperty()
203     {
204         return this.byteProperty;
205     }
206 
207     public void setByteProperty( final byte value )
208     {
209         this.byteProperty = value;
210     }
211 
212     public Byte getBoxedByteProperty()
213     {
214         return this.boxedByteProperty;
215     }
216 
217     public void setBoxedByteProperty( final byte value )
218     {
219         this.boxedByteProperty = value;
220     }
221 
222     public byte getUnboxedByteProperty()
223     {
224         return this.unboxedByteProperty;
225     }
226 
227     public void setUnboxedByteProperty( final Byte value )
228     {
229         this.unboxedByteProperty = value;
230     }
231 
232     public short getShortProperty()
233     {
234         return this.shortProperty;
235     }
236 
237     public void setShortProperty( final short value )
238     {
239         this.shortProperty = value;
240     }
241 
242     public Short getBoxedShortProperty()
243     {
244         return this.boxedShortProperty;
245     }
246 
247     public void setBoxedShortProperty( final short value )
248     {
249         this.boxedShortProperty = value;
250     }
251 
252     public short getUnboxedShortProperty()
253     {
254         return this.unboxedShortProperty;
255     }
256 
257     public void setUnboxedShortProperty( final Short value )
258     {
259         this.unboxedShortProperty = value;
260     }
261 
262     public int getIntProperty()
263     {
264         return this.intProperty;
265     }
266 
267     public void setIntProperty( final int value )
268     {
269         this.intProperty = value;
270     }
271 
272     public Integer getBoxedIntProperty()
273     {
274         return this.boxedIntProperty;
275     }
276 
277     public void setBoxedIntProperty( final int value )
278     {
279         this.boxedIntProperty = value;
280     }
281 
282     public int getUnboxedIntProperty()
283     {
284         return this.unboxedIntProperty;
285     }
286 
287     public void setUnboxedIntProperty( final Integer value )
288     {
289         this.unboxedIntProperty = value;
290     }
291 
292     public long getLongProperty()
293     {
294         return this.longProperty;
295     }
296 
297     public void setLongProperty( final long value )
298     {
299         this.longProperty = value;
300     }
301 
302     public Long getBoxedLongProperty()
303     {
304         return this.boxedLongProperty;
305     }
306 
307     public void setBoxedLongProperty( final long value )
308     {
309         this.boxedLongProperty = value;
310     }
311 
312     public long getUnboxedLongProperty()
313     {
314         return this.unboxedLongProperty;
315     }
316 
317     public void setUnboxedLongProperty( final Long value )
318     {
319         this.unboxedLongProperty = value;
320     }
321 
322     public float getFloatProperty()
323     {
324         return this.floatProperty;
325     }
326 
327     public void setFloatProperty( final float value )
328     {
329         this.floatProperty = value;
330     }
331 
332     public Float getBoxedFloatProperty()
333     {
334         return this.boxedFloatProperty;
335     }
336 
337     public void setBoxedFloatProperty( final float value )
338     {
339         this.boxedFloatProperty = value;
340     }
341 
342     public float getUnboxedFloatProperty()
343     {
344         return this.unboxedFloatProperty;
345     }
346 
347     public void setUnboxedFloatProperty( final Float value )
348     {
349         this.unboxedFloatProperty = value;
350     }
351 
352     public double getDoubleProperty()
353     {
354         return this.doubleProperty;
355     }
356 
357     public void setDoubleProperty( final double value )
358     {
359         this.doubleProperty = value;
360     }
361 
362     public Double getBoxedDoubleProperty()
363     {
364         return this.boxedDoubleProperty;
365     }
366 
367     public void setBoxedDoubleProperty( final double value )
368     {
369         this.boxedDoubleProperty = value;
370     }
371 
372     public double getUnboxedDoubleProperty()
373     {
374         return this.unboxedDoubleProperty;
375     }
376 
377     public void setUnboxedDoubleProperty( final Double value )
378     {
379         this.unboxedDoubleProperty = value;
380     }
381 
382     public String getStringProperty()
383     {
384         return this.stringProperty;
385     }
386 
387     public void setStringProperty( final String value )
388     {
389         this.stringProperty = value;
390     }
391 
392     public String getStringPropertyWithoutSetter()
393     {
394         return this.stringPropertyWithoutSetter;
395     }
396 
397     public void setStringPropertyWithoutGetter( final String value )
398     {
399         this.stringPropertyWithoutGetter = value;
400     }
401 
402     public URL getUrlProperty()
403     {
404         return this.urlProperty;
405     }
406 
407     public void setUrlProperty( final URL value )
408     {
409         this.urlProperty = value;
410     }
411 
412     public Thread.State getEnumProperty()
413     {
414         return this.enumProperty;
415     }
416 
417     public void setEnumProperty( final Thread.State value )
418     {
419         this.enumProperty = value;
420     }
421 
422     public Object getObjectProperty()
423     {
424         return this.objectProperty;
425     }
426 
427     public void setObjectProperty( final Object value )
428     {
429         this.objectProperty = value;
430     }
431 
432     public Math getUnsupportedPropertyType()
433     {
434         return this.unsupportedPropertyType;
435     }
436 
437     public void setUnsupportedPropertyType( final Math value )
438     {
439         this.unsupportedPropertyType = value;
440     }
441 
442     public InstantiationExceptionPropertyType getInstantiationExceptionProperty()
443     {
444         return this.instantiationExceptionProperty;
445     }
446 
447     public void setInstantiationExceptionProperty( final InstantiationExceptionPropertyType value )
448     {
449         this.instantiationExceptionProperty = value;
450     }
451 
452     public InvocationTargetExceptionPropertyType getInvocationTargetExceptionProperty()
453     {
454         return this.invocationTargetExceptionProperty;
455     }
456 
457     public void setInvocationTargetExceptionProperty( final InvocationTargetExceptionPropertyType value )
458     {
459         this.invocationTargetExceptionProperty = value;
460     }
461 
462 }