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 3958 2011-11-18 22:32:23Z schulte2005 $
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:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
045 * @version $JOMC: TestModelProcessor.java 3958 2011-11-18 22:32:23Z schulte2005 $
046 */
047public final class TestModelProcessor implements ModelProcessor
048{
049
050    private boolean booleanProperty;
051
052    private char characterProperty;
053
054    private byte byteProperty;
055
056    private short shortProperty;
057
058    private int intProperty;
059
060    private long longProperty;
061
062    private float floatProperty;
063
064    private double doubleProperty;
065
066    private String stringProperty;
067
068    private String stringPropertyWithoutSetter;
069
070    private String stringPropertyWithoutGetter;
071
072    private URL urlProperty;
073
074    private Thread.State enumProperty;
075
076    private Object objectProperty;
077
078    public TestModelProcessor()
079    {
080        super();
081    }
082
083    public Model processModel( final ModelContext context, final Model model ) throws ModelException
084    {
085        if ( context == null )
086        {
087            throw new NullPointerException( "context" );
088        }
089        if ( model == null )
090        {
091            throw new NullPointerException( "model" );
092        }
093
094        context.setAttribute( TestModelProcessor.class.getName(), this );
095
096        final Model processed = model.clone();
097        final TestComplexType t = processed.getAnyObject( TestComplexType.class );
098        assertNotNull( t );
099
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}