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: TestModelProcessor.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.ModelProcessor; 038import org.jomc.modlet.test.TestComplexType; 039import static org.junit.Assert.assertNotNull; 040 041/** 042 * {@code ModelProcessor} test implementation. 043 * 044 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0 045 * @version $JOMC: TestModelProcessor.java 4654 2012-11-15 22:28:26Z schulte $ 046 */ 047public final class TestModelProcessor implements ModelProcessor 048{ 049 050 private boolean booleanProperty; 051 052 private boolean boxedBooleanProperty; 053 054 private Boolean unboxedBooleanProperty; 055 056 private char characterProperty; 057 058 private char boxedCharacterProperty; 059 060 private Character unboxedCharacterProperty; 061 062 private byte byteProperty; 063 064 private byte boxedByteProperty; 065 066 private Byte unboxedByteProperty; 067 068 private short shortProperty; 069 070 private short boxedShortProperty; 071 072 private Short unboxedShortProperty; 073 074 private int intProperty; 075 076 private int boxedIntProperty; 077 078 private Integer unboxedIntProperty; 079 080 private long longProperty; 081 082 private long boxedLongProperty; 083 084 private Long unboxedLongProperty; 085 086 private float floatProperty; 087 088 private float boxedFloatProperty; 089 090 private Float unboxedFloatProperty; 091 092 private double doubleProperty; 093 094 private double boxedDoubleProperty; 095 096 private Double unboxedDoubleProperty; 097 098 private String stringProperty; 099 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}