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