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 3958 2011-11-18 22:32:23Z schulte2005 $
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:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
45   * @version $JOMC: TestModelProcessor.java 3958 2011-11-18 22:32:23Z schulte2005 $
46   */
47  public final class TestModelProcessor implements ModelProcessor
48  {
49  
50      private boolean booleanProperty;
51  
52      private char characterProperty;
53  
54      private byte byteProperty;
55  
56      private short shortProperty;
57  
58      private int intProperty;
59  
60      private long longProperty;
61  
62      private float floatProperty;
63  
64      private double doubleProperty;
65  
66      private String stringProperty;
67  
68      private String stringPropertyWithoutSetter;
69  
70      private String stringPropertyWithoutGetter;
71  
72      private URL urlProperty;
73  
74      private Thread.State enumProperty;
75  
76      private Object objectProperty;
77  
78      public TestModelProcessor()
79      {
80          super();
81      }
82  
83      public Model processModel( final ModelContext context, final Model model ) throws ModelException
84      {
85          if ( context == null )
86          {
87              throw new NullPointerException( "context" );
88          }
89          if ( model == null )
90          {
91              throw new NullPointerException( "model" );
92          }
93  
94          context.setAttribute( TestModelProcessor.class.getName(), this );
95  
96          final Model processed = model.clone();
97          final TestComplexType t = processed.getAnyObject( TestComplexType.class );
98          assertNotNull( t );
99  
100         t.getAny().add( new TestComplexType() );
101         return processed;
102     }
103 
104     public boolean isBooleanProperty()
105     {
106         return this.booleanProperty;
107     }
108 
109     public void setBooleanProperty( final boolean value )
110     {
111         this.booleanProperty = value;
112     }
113 
114     public char getCharacterProperty()
115     {
116         return this.characterProperty;
117     }
118 
119     public void setCharacterProperty( final char value )
120     {
121         this.characterProperty = value;
122     }
123 
124     public byte getByteProperty()
125     {
126         return this.byteProperty;
127     }
128 
129     public void setByteProperty( final byte value )
130     {
131         this.byteProperty = value;
132     }
133 
134     public short getShortProperty()
135     {
136         return this.shortProperty;
137     }
138 
139     public void setShortProperty( final short value )
140     {
141         this.shortProperty = value;
142     }
143 
144     public int getIntProperty()
145     {
146         return this.intProperty;
147     }
148 
149     public void setIntProperty( final int value )
150     {
151         this.intProperty = value;
152     }
153 
154     public long getLongProperty()
155     {
156         return this.longProperty;
157     }
158 
159     public void setLongProperty( final long value )
160     {
161         this.longProperty = value;
162     }
163 
164     public float getFloatProperty()
165     {
166         return this.floatProperty;
167     }
168 
169     public void setFloatProperty( final float value )
170     {
171         this.floatProperty = value;
172     }
173 
174     public double getDoubleProperty()
175     {
176         return this.doubleProperty;
177     }
178 
179     public void setDoubleProperty( final double value )
180     {
181         this.doubleProperty = value;
182     }
183 
184     public String getStringProperty()
185     {
186         return this.stringProperty;
187     }
188 
189     public void setStringProperty( final String value )
190     {
191         this.stringProperty = value;
192     }
193 
194     public String getStringPropertyWithoutSetter()
195     {
196         return this.stringPropertyWithoutSetter;
197     }
198 
199     public void setStringPropertyWithoutGetter( final String value )
200     {
201         this.stringPropertyWithoutGetter = value;
202     }
203 
204     public URL getUrlProperty()
205     {
206         return this.urlProperty;
207     }
208 
209     public void setUrlProperty( final URL value )
210     {
211         this.urlProperty = value;
212     }
213 
214     public Thread.State getEnumProperty()
215     {
216         return this.enumProperty;
217     }
218 
219     public void setEnumProperty( final Thread.State value )
220     {
221         this.enumProperty = value;
222     }
223 
224     public Object getObjectProperty()
225     {
226         return this.objectProperty;
227     }
228 
229     public void setObjectProperty( final Object value )
230     {
231         this.objectProperty = value;
232     }
233 
234 }