001//
002// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 
003// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
004// Any modifications to this file will be lost upon recompilation of the source schema. 
005// Generated on: 2016.11.01 at 03:16:38 AM CET 
006//
007
008
009package org.jomc.model;
010
011import java.util.ArrayList;
012import java.util.Iterator;
013import java.util.List;
014import javax.annotation.Generated;
015import javax.xml.bind.annotation.XmlAccessType;
016import javax.xml.bind.annotation.XmlAccessorType;
017import javax.xml.bind.annotation.XmlElement;
018import javax.xml.bind.annotation.XmlType;
019
020
021/**
022 * List of specifications.
023 * 
024 * <p>Java class for Specifications complex type.
025 * 
026 * <p>The following schema fragment specifies the expected content contained within this class.
027 * 
028 * <pre>
029 * &lt;complexType name="Specifications">
030 *   &lt;complexContent>
031 *     &lt;extension base="{http://jomc.org/model}ModelObject">
032 *       &lt;sequence>
033 *         &lt;element ref="{http://jomc.org/model}specification" maxOccurs="unbounded" minOccurs="0"/>
034 *         &lt;element name="reference" type="{http://jomc.org/model}SpecificationReference" maxOccurs="unbounded" minOccurs="0"/>
035 *       &lt;/sequence>
036 *     &lt;/extension>
037 *   &lt;/complexContent>
038 * &lt;/complexType>
039 * </pre>
040 * 
041 * 
042 */
043@XmlAccessorType(XmlAccessType.FIELD)
044@XmlType(name = "Specifications", namespace = "http://jomc.org/model", propOrder = {
045    "specification",
046    "reference"
047})
048@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
049public class Specifications
050    extends ModelObject
051    implements Cloneable
052{
053
054    @XmlElement(namespace = "http://jomc.org/model")
055    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
056    protected List<Specification> specification;
057    @XmlElement(namespace = "http://jomc.org/model")
058    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
059    protected List<SpecificationReference> reference;
060
061    /**
062     * Creates a new {@code Specifications} instance.
063     * 
064     */
065    public Specifications() {
066        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
067        super();
068    }
069
070    /**
071     * Creates a new {@code Specifications} instance by deeply copying a given {@code Specifications} instance.
072     * 
073     * 
074     * @param o
075     *     The instance to copy.
076     * @throws NullPointerException
077     *     if {@code o} is {@code null}.
078     */
079    public Specifications(final Specifications o) {
080        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
081        super(o);
082        if (o == null) {
083            throw new NullPointerException("Cannot create a copy of 'Specifications' from 'null'.");
084        }
085        // 'Specification' collection.
086        if (o.specification!= null) {
087            copySpecification(o.getSpecification(), this.getSpecification());
088        }
089        // 'Reference' collection.
090        if (o.reference!= null) {
091            copyReference(o.getReference(), this.getReference());
092        }
093    }
094
095    /**
096     * Gets the value of the specification property.
097     * 
098     * <p>
099     * This accessor method returns a reference to the live list,
100     * not a snapshot. Therefore any modification you make to the
101     * returned list will be present inside the JAXB object.
102     * This is why there is not a <CODE>set</CODE> method for the specification property.
103     * 
104     * <p>
105     * For example, to add a new item, do as follows:
106     * <pre>
107     *    getSpecification().add(newItem);
108     * </pre>
109     * 
110     * 
111     * <p>
112     * Objects of the following type(s) are allowed in the list
113     * {@link Specification }
114     * 
115     * 
116     */
117    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
118    public List<Specification> getSpecification() {
119        if (specification == null) {
120            specification = new ArrayList<Specification>();
121        }
122        return this.specification;
123    }
124
125    /**
126     * Gets the value of the reference property.
127     * 
128     * <p>
129     * This accessor method returns a reference to the live list,
130     * not a snapshot. Therefore any modification you make to the
131     * returned list will be present inside the JAXB object.
132     * This is why there is not a <CODE>set</CODE> method for the reference property.
133     * 
134     * <p>
135     * For example, to add a new item, do as follows:
136     * <pre>
137     *    getReference().add(newItem);
138     * </pre>
139     * 
140     * 
141     * <p>
142     * Objects of the following type(s) are allowed in the list
143     * {@link SpecificationReference }
144     * 
145     * 
146     */
147    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
148    public List<SpecificationReference> getReference() {
149        if (reference == null) {
150            reference = new ArrayList<SpecificationReference>();
151        }
152        return this.reference;
153    }
154
155    /**
156     * Copies all values of property {@code Specification} deeply.
157     * 
158     * @param source
159     *     The source to copy from.
160     * @param target
161     *     The target to copy {@code source} to.
162     * @throws NullPointerException
163     *     if {@code target} is {@code null}.
164     */
165    @SuppressWarnings("unchecked")
166    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
167    private static void copySpecification(final List<Specification> source, final List<Specification> target) {
168        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
169        if ((source!= null)&&(!source.isEmpty())) {
170            for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
171                final Object next = it.next();
172                if (next instanceof Specification) {
173                    // CClassInfo: org.jomc.model.Specification
174                    target.add(((Specification) next).clone());
175                    continue;
176                }
177                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
178                throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Specification' of class 'org.jomc.model.Specifications'."));
179            }
180        }
181    }
182
183    /**
184     * Copies all values of property {@code Reference} deeply.
185     * 
186     * @param source
187     *     The source to copy from.
188     * @param target
189     *     The target to copy {@code source} to.
190     * @throws NullPointerException
191     *     if {@code target} is {@code null}.
192     */
193    @SuppressWarnings("unchecked")
194    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
195    private static void copyReference(final List<SpecificationReference> source, final List<SpecificationReference> target) {
196        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
197        if ((source!= null)&&(!source.isEmpty())) {
198            for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
199                final Object next = it.next();
200                if (next instanceof SpecificationReference) {
201                    // CClassInfo: org.jomc.model.SpecificationReference
202                    target.add(((SpecificationReference) next).clone());
203                    continue;
204                }
205                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
206                throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Reference' of class 'org.jomc.model.Specifications'."));
207            }
208        }
209    }
210
211    /**
212     * Creates and returns a deep copy of this object.
213     * 
214     * 
215     * @return
216     *     A deep copy of this object.
217     */
218    @Override
219    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:16:37+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
220    public Specifications clone() {
221        {
222            // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
223            final Specifications clone = ((Specifications) super.clone());
224            // 'Specification' collection.
225            if (this.specification!= null) {
226                clone.specification = null;
227                copySpecification(this.getSpecification(), clone.getSpecification());
228            }
229            // 'Reference' collection.
230            if (this.reference!= null) {
231                clone.reference = null;
232                copyReference(this.getReference(), clone.getReference());
233            }
234            return clone;
235        }
236    }
237    
238    /**
239     * Gets a specification for a given identifier from the list of specifications.
240     *
241     * @param specification The identifier of the specification to return.
242     *
243     * @return The first matching specification or {@code null}, if no such specification is found.
244     *
245     * @throws NullPointerException if {@code specification} is {@code null}.
246     *
247     * @see #getSpecification()
248     * @see Specification#getIdentifier()
249     */
250    public Specification getSpecification( final String specification )
251    {
252        if ( specification == null )
253        {
254            throw new NullPointerException( "specification" );
255        }
256
257        for ( int i = 0, s0 = this.getSpecification().size(); i < s0; i++ )
258        {
259            final Specification s = this.getSpecification().get( i );
260
261            if ( specification.equals( s.getIdentifier() ) )
262            {
263                return s;
264            }
265        }
266
267        return null;
268    }
269
270    /**
271     * Gets a specification for a given class from the list of specifications.
272     *
273     * @param specification The class of the specification to return.
274     *
275     * @return The first matching specification declaring {@code specification} or {@code null}, if no such
276     * specification is found.
277     *
278     * @throws NullPointerException if {@code specification} is {@code null}.
279     * @throws ModelObjectException if compiling the name of a referenced type to a {@code JavaTypeName} fails.
280     *
281     * @see #getSpecification()
282     * @see Specification#isClassDeclaration()
283     * @see Specification#getClazz()
284     */
285    public Specification getSpecification( final Class<?> specification ) throws ModelObjectException
286    {
287        if ( specification == null )
288        {
289            throw new NullPointerException( "specification" );
290        }
291
292        for ( int i = 0, s0 = this.getSpecification().size(); i < s0; i++ )
293        {
294            final Specification s = this.getSpecification().get( i );
295
296            if ( s.isClassDeclaration() && s.getClazz() != null )
297            {
298                if ( specification.getName().equals( s.getJavaTypeName().getClassName() ) )
299                {
300                    return s;
301                }
302            }
303        }
304
305        return null;
306    }
307
308    /**
309     * Gets a specification reference for a given identifier from the list of references.
310     *
311     * @param specification The identifier of the reference to return.
312     *
313     * @return The first matching specification reference or {@code null}, if no such specification reference is found.
314     *
315     * @throws NullPointerException if {@code specification} is {@code null}.
316     *
317     * @see #getReference()
318     * @see SpecificationReference#getIdentifier()
319     */
320    public SpecificationReference getReference( final String specification )
321    {
322        if ( specification == null )
323        {
324            throw new NullPointerException( "specification" );
325        }
326
327        for ( int i = 0, s0 = this.getReference().size(); i < s0; i++ )
328        {
329            final SpecificationReference r = this.getReference().get( i );
330
331            if ( specification.equals( r.getIdentifier() ) )
332            {
333                return r;
334            }
335        }
336
337        return null;
338    }
339      
340}