ToolsType.java

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2015.05.31 at 05:43:54 PM CEST 
//


package org.jomc.tools.model;

import javax.annotation.Generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;


/**
 * Base tools type.
 * 
 * <p>Java class for ToolsType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="ToolsType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;attribute name="modelVersion" type="{http://www.w3.org/2001/XMLSchema}string" default="1.6" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ToolsType", namespace = "http://jomc.org/tools/model")
@XmlSeeAlso({
    SourceSectionType.class,
    SourceSectionsType.class,
    SourceFileType.class,
    SourceFilesType.class,
    TemplateParameterType.class
})
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
public class ToolsType implements Cloneable
{

    @XmlAttribute(name = "modelVersion")
    @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
    protected String modelVersion;

    /**
     * Creates a new {@code ToolsType} instance.
     * 
     */
    public ToolsType() {
        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
        super();
    }

    /**
     * Creates a new {@code ToolsType} instance by deeply copying a given {@code ToolsType} instance.
     * 
     * 
     * @param o
     *     The instance to copy.
     * @throws NullPointerException
     *     if {@code o} is {@code null}.
     */
    public ToolsType(final ToolsType o) {
        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
        super();
        if (o == null) {
            throw new NullPointerException("Cannot create a copy of 'ToolsType' from 'null'.");
        }
        // CBuiltinLeafInfo: java.lang.String
        this.modelVersion = ((o.modelVersion == null)?null:o.getModelVersion());
    }

    /**
     * Gets the value of the modelVersion property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
    public String getModelVersion() {
        if (modelVersion == null) {
            return "1.6";
        } else {
            return modelVersion;
        }
    }

    /**
     * Sets the value of the modelVersion property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
    public void setModelVersion(String value) {
        this.modelVersion = value;
    }

    /**
     * Creates and returns a deep copy of this object.
     * 
     * 
     * @return
     *     A deep copy of this object.
     */
    @Override
    @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
    public ToolsType clone() {
        try {
            {
                // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
                final ToolsType clone = ((ToolsType) super.clone());
                // CBuiltinLeafInfo: java.lang.String
                clone.modelVersion = ((this.modelVersion == null)?null:this.getModelVersion());
                return clone;
            }
        } catch (CloneNotSupportedException e) {
            // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
            throw new AssertionError(e);
        }
    }
    
    /**
     * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
     *
     * @param any The list to search.
     * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
     * @param localPart The local part of the {@code JAXBElement} to return.
     * @param type The class of the type the element is bound to.
     * @param <T> The type the element is bound to.
     *
     * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
     * {@code null} if no such element is found.
     *
     * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
     * {@code null}.
     * @throws IllegalStateException if {@code any} contains more than one matching element.
     */
    protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any,
                                                               final String namespaceURI,
                                                               final String localPart,
                                                               final Class<T> type )
    {
        if ( any == null )
        {
            throw new NullPointerException( "any" );
        }
        if ( namespaceURI == null )
        {
            throw new NullPointerException( "namespaceURI" );
        }
        if ( localPart == null )
        {
            throw new NullPointerException( "localPart" );
        }
        if ( type == null )
        {
            throw new NullPointerException( "type" );
        }

        javax.xml.bind.JAXBElement<?> anyElement = null;

        for ( int i = 0, s0 = any.size(); i < s0; i++ )
        {
            final Object o = any.get( i );

            if ( o instanceof javax.xml.bind.JAXBElement<?> )
            {
                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;

                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
                     && localPart.equals( e.getName().getLocalPart() ) )
                {
                    if ( anyElement == null )
                    {
                        anyElement = e;
                    }
                    else
                    {
                        throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
                                                                     namespaceURI, localPart ) );

                    }
                }
            }
        }

        if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) )
        {
            @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e =
                (javax.xml.bind.JAXBElement<T>) anyElement;

            return e;
        }

        return null;
    }

    /**
     * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
     * objects.
     *
     * @param any The list to search.
     * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
     * @param localPart The local part of the {@code JAXBElement}s to return.
     * @param type The class of the type the elements are bound to.
     * @param <T> The type the elements are bound to.
     *
     * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
     * the {@code any} list - an empty list if no such elements are found.
     *
     * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
     * {@code null}.
     */
    protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any,
                                                                                final String namespaceURI,
                                                                                final String localPart,
                                                                                final Class<T> type )
    {
        if ( any == null )
        {
            throw new NullPointerException( "any" );
        }
        if ( namespaceURI == null )
        {
            throw new NullPointerException( "namespaceURI" );
        }
        if ( localPart == null )
        {
            throw new NullPointerException( "localPart" );
        }
        if ( type == null )
        {
            throw new NullPointerException( "type" );
        }

        final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements =
            new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() );

        for ( int i = 0, s0 = any.size(); i < s0; i++ )
        {
            final Object o = any.get( i );

            if ( o instanceof javax.xml.bind.JAXBElement<?> )
            {
                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;

                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
                     && localPart.equals( e.getName().getLocalPart() )
                     && e.getValue() != null && e.getValue().getClass().equals( type ) )
                {
                    @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement =
                        (javax.xml.bind.JAXBElement<T>) e;

                    anyElements.add( anyElement );
                }
            }
        }

        return java.util.Collections.unmodifiableList( anyElements );
    }

    /**
     * Gets a single object matching a class from a given list of objects.
     *
     * @param any The list to search.
     * @param clazz The class to return an instance of.
     * @param <T> The type of the object to return.
     *
     * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found.
     *
     * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
     * @throws IllegalStateException if {@code any} contains more than one matching object.
     */
    protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz )
    {
        if ( any == null )
        {
            throw new NullPointerException( "any" );
        }
        if ( clazz == null )
        {
            throw new NullPointerException( "clazz" );
        }

        T anyObject = null;

        for ( int i = 0, s0 = any.size(); i < s0; i++ )
        {
            Object o = any.get( i );

            if ( o instanceof javax.xml.bind.JAXBElement<?> )
            {
                o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
            }

            if ( clazz.equals( o.getClass() ) )
            {
                if ( anyObject == null )
                {
                    @SuppressWarnings( "unchecked" ) final T object = (T) o;
                    anyObject = object;
                }
                else
                {
                    throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(),
                                                                 clazz.getName() ) );

                }
            }
        }

        return anyObject;
    }

    /**
     * Gets a list containing all objects matching a class from a given list of objects.
     *
     * @param any The list to search.
     * @param clazz The class to return all instances of.
     * @param <T> The type of the objects to return.
     *
     * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no
     * such objects are found.
     *
     * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
     */
    protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz )
    {
        if ( any == null )
        {
            throw new NullPointerException( "any" );
        }
        if ( clazz == null )
        {
            throw new NullPointerException( "namespaceURI" );
        }

        final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() );

        for ( int i = 0, s0 = any.size(); i < s0; i++ )
        {
            Object o = any.get( i );

            if ( o instanceof javax.xml.bind.JAXBElement<?> )
            {
                o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
            }

            if ( clazz.equals( o.getClass() ) )
            {
                @SuppressWarnings( "unchecked" ) final T object = (T) o;
                anyElements.add( object );
            }
        }

        return java.util.Collections.unmodifiableList( anyElements );
    }

    private static String getMessage( final String key, final Object... args )
    {
        return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
            ToolsType.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
            getString( key ), args );
    }
      
}