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