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.09.01 at 05:41:23 AM CEST 
006//
007
008
009package org.jomc.modlet;
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 services.
023 * 
024 * <p>Java class for Services complex type.
025 * 
026 * <p>The following schema fragment specifies the expected content contained within this class.
027 * 
028 * <pre>
029 * &lt;complexType name="Services">
030 *   &lt;complexContent>
031 *     &lt;extension base="{http://jomc.org/modlet}ModletObject">
032 *       &lt;sequence>
033 *         &lt;element ref="{http://jomc.org/modlet}service" maxOccurs="unbounded" minOccurs="0"/>
034 *       &lt;/sequence>
035 *     &lt;/extension>
036 *   &lt;/complexContent>
037 * &lt;/complexType>
038 * </pre>
039 * 
040 * 
041 */
042@XmlAccessorType(XmlAccessType.FIELD)
043@XmlType(name = "Services", namespace = "http://jomc.org/modlet", propOrder = {
044    "service"
045})
046@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-09-01T05:41:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
047public class Services
048    extends ModletObject
049    implements Cloneable
050{
051
052    @XmlElement(namespace = "http://jomc.org/modlet")
053    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-09-01T05:41:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
054    protected List<Service> service;
055
056    /**
057     * Creates a new {@code Services} instance.
058     * 
059     */
060    public Services() {
061        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
062        super();
063    }
064
065    /**
066     * Creates a new {@code Services} instance by deeply copying a given {@code Services} instance.
067     * 
068     * 
069     * @param o
070     *     The instance to copy.
071     * @throws NullPointerException
072     *     if {@code o} is {@code null}.
073     */
074    public Services(final Services o) {
075        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
076        super(o);
077        if (o == null) {
078            throw new NullPointerException("Cannot create a copy of 'Services' from 'null'.");
079        }
080        // 'Service' collection.
081        if (o.service!= null) {
082            copyService(o.getService(), this.getService());
083        }
084    }
085
086    /**
087     * Gets the value of the service property.
088     * 
089     * <p>
090     * This accessor method returns a reference to the live list,
091     * not a snapshot. Therefore any modification you make to the
092     * returned list will be present inside the JAXB object.
093     * This is why there is not a <CODE>set</CODE> method for the service property.
094     * 
095     * <p>
096     * For example, to add a new item, do as follows:
097     * <pre>
098     *    getService().add(newItem);
099     * </pre>
100     * 
101     * 
102     * <p>
103     * Objects of the following type(s) are allowed in the list
104     * {@link Service }
105     * 
106     * 
107     */
108    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-09-01T05:41:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
109    public List<Service> getService() {
110        if (service == null) {
111            service = new ArrayList<Service>();
112        }
113        return this.service;
114    }
115
116    /**
117     * Copies all values of property {@code Service} deeply.
118     * 
119     * @param source
120     *     The source to copy from.
121     * @param target
122     *     The target to copy {@code source} to.
123     * @throws NullPointerException
124     *     if {@code target} is {@code null}.
125     */
126    @SuppressWarnings("unchecked")
127    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-09-01T05:41:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
128    private static void copyService(final List<Service> source, final List<Service> target) {
129        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
130        if ((source!= null)&&(!source.isEmpty())) {
131            for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
132                final Object next = it.next();
133                if (next instanceof Service) {
134                    // CClassInfo: org.jomc.modlet.Service
135                    target.add(((Service) next).clone());
136                    continue;
137                }
138                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
139                throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Service' of class 'org.jomc.modlet.Services'."));
140            }
141        }
142    }
143
144    /**
145     * Creates and returns a deep copy of this object.
146     * 
147     * 
148     * @return
149     *     A deep copy of this object.
150     */
151    @Override
152    @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-09-01T05:41:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
153    public Services clone() {
154        {
155            // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
156            final Services clone = ((Services) super.clone());
157            // 'Service' collection.
158            if (this.service!= null) {
159                clone.service = null;
160                copyService(this.getService(), clone.getService());
161            }
162            return clone;
163        }
164    }
165    
166    /**
167     * Gets all services for a given identifier from this list of services.
168     *
169     * @param identifier The identifier of the services to return.
170     *
171     * @return An unmodifiable, sorted list holding services matching {@code identifier} from the list or an empty list
172     * if no services matching {@code identifier} are found.
173     *
174     * @throws NullPointerException if {@code identifier} is {@code null}.
175     *
176     * @see #getService()
177     */
178    public List<Service> getServices( final String identifier )
179    {
180        if ( identifier == null )
181        {
182            throw new NullPointerException( "identifier" );
183        }
184
185        final java.util.List<Service> services = new java.util.ArrayList<Service>( this.getService().size() );
186
187        for ( int i = 0, s0 = this.getService().size(); i < s0; i++ )
188        {
189            final Service s = this.getService().get( i );
190
191            if ( identifier.equals( s.getIdentifier() ) )
192            {
193                services.add( s );
194            }
195        }
196
197        java.util.Collections.sort( services, new java.util.Comparator<Service>()
198        {
199
200            public int compare( final Service s1, final Service s2 )
201            {
202                return s1.getOrdinal() - s2.getOrdinal();
203            }
204
205        } );
206
207        return java.util.Collections.unmodifiableList( services );
208    }
209
210    /**
211     * Gets all services for a given class from this list of services.
212     *
213     * @param clazz The class of the services to return.
214     *
215     * @return An unmodifiable, sorted list holding services matching {@code class} from the list or an empty list
216     * if no services matching {@code clazz} are found.
217     *
218     * @throws NullPointerException if {@code clazz} is {@code null}.
219     *
220     * @see #getService()
221     */
222    public List<Service> getServices( final Class<?> clazz )
223    {
224        if ( clazz == null )
225        {
226            throw new NullPointerException( "clazz" );
227        }
228
229        return this.getServices( clazz.getName() );
230    }
231
232      
233}