//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.5-b01-fcs
// 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: 2008.06.26 at 12:02:13 PM CEST
//


package org.w3._2005._08.addressing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.jvnet.hyperjaxb3.item.Item;
import org.jvnet.hyperjaxb3.item.ItemUtils;
import org.jvnet.hyperjaxb3.xml.bind.JAXBContextUtils;
import org.jvnet.hyperjaxb3.xml.bind.annotation.adapters.ElementAsString;
import org.jvnet.hyperjaxb3.xml.bind.annotation.adapters.XmlAdapterUtils;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.builder.JAXBEqualsBuilder;
import org.jvnet.jaxb2_commons.lang.builder.JAXBHashCodeBuilder;
import org.jvnet.jaxb2_commons.lang.builder.JAXBToStringBuilder;
import org.w3c.dom.Element;


/**
 * <p>Java class for EndpointReferenceType complex type.
 *
 * <p>The following schema fragment specifies the expected content contained within this class.
 *
 * <pre>
 * &lt;complexType name="EndpointReferenceType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="Address" type="{http://www.w3.org/2005/08/addressing}AttributedURIType"/>
 *         &lt;element name="ReferenceParameters" type="{http://www.w3.org/2005/08/addressing}ReferenceParametersType" minOccurs="0"/>
 *         &lt;element ref="{http://www.w3.org/2005/08/addressing}Metadata" minOccurs="0"/>
 *         &lt;any/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(namespace="http://www.w3.org/2005/08/addressing", name="EndpointReference")
@XmlType(name = "EndpointReferenceType", propOrder = {
    "address",
    "referenceParameters",
    "metadata",
    "any"
})
@Entity(name = "org.w3._2005._08.addressing.EndpointReferenceType")
@Table(name = "ENDPOINTREFERENCETYPE")
@Inheritance(strategy = InheritanceType.JOINED)
public class EndpointReferenceType
    implements Equals, HashCode, ToString
{

    @XmlElement(name = "Address", required = true)
    protected AttributedURIType address;
    @XmlElement(name = "ReferenceParameters")
    protected ReferenceParametersType referenceParameters;
    @XmlElement(name = "Metadata")
    protected MetadataType metadata;
    @XmlAnyElement(lax = true)
    protected List<Object> any;
    @XmlAnyAttribute
    private Map<QName, String> otherAttributes = new HashMap<QName, String>();
    @XmlAttribute
    protected Long hjid;
    @XmlTransient
    protected List<EndpointReferenceType.AnyItem> anyItems;

    /**
     * Gets the value of the address property.
     *
     * @return
     *     possible object is
     *     {@link AttributedURIType }
     *
     */
    @ManyToOne(cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "ADDRESS_ATTRIBUTEDURITYPE_ID")
    public AttributedURIType getAddress() {
        return address;
    }

    /**
     * Sets the value of the address property.
     *
     * @param value
     *     allowed object is
     *     {@link AttributedURIType }
     *
     */
    public void setAddress(AttributedURIType value) {
        this.address = value;
    }

    /**
     * Gets the value of the referenceParameters property.
     *
     * @return
     *     possible object is
     *     {@link ReferenceParametersType }
     *
     */
    @ManyToOne(cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "REFERENCEPARAMETERS_REFERENC_0")
    public ReferenceParametersType getReferenceParameters() {
        return referenceParameters;
    }

    /**
     * Sets the value of the referenceParameters property.
     *
     * @param value
     *     allowed object is
     *     {@link ReferenceParametersType }
     *
     */
    public void setReferenceParameters(ReferenceParametersType value) {
        this.referenceParameters = value;
    }

    /**
     * Gets the value of the metadata property.
     *
     * @return
     *     possible object is
     *     {@link MetadataType }
     *
     */
    @ManyToOne(cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "METADATA_METADATATYPE_ID")
    public MetadataType getMetadata() {
        return metadata;
    }

    /**
     * Sets the value of the metadata property.
     *
     * @param value
     *     allowed object is
     *     {@link MetadataType }
     *
     */
    public void setMetadata(MetadataType value) {
        this.metadata = value;
    }

    /**
     * Gets the value of the any property.
     *
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the any property.
     *
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getAny().add(newItem);
     * </pre>
     *
     *
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Element }
     * {@link Object }
     *
     *
     */
    @Transient
    public List<Object> getAny() {
        if (any == null) {
            any = new ArrayList<Object>();
        }
        return this.any;
    }

    /**
     *
     *
     */
    public void setAny(List<Object> any) {
        this.any = any;
    }

    /**
     * Gets a map that contains attributes that aren't bound to any typed property on this class.
     *
     * <p>
     * the map is keyed by the name of the attribute and
     * the value is the string value of the attribute.
     *
     * the map returned by this method is live, and you can add new attribute
     * by updating the map directly. Because of this design, there's no setter.
     *
     *
     * @return
     *     always non-null
     */
    @Transient
    public Map<QName, String> getOtherAttributes() {
        return otherAttributes;
    }

    public void toString(ToStringBuilder toStringBuilder) {
        {
            AttributedURIType theAddress;
            theAddress = this.getAddress();
            toStringBuilder.append("address", theAddress);
        }
        {
            ReferenceParametersType theReferenceParameters;
            theReferenceParameters = this.getReferenceParameters();
            toStringBuilder.append("referenceParameters", theReferenceParameters);
        }
        {
            MetadataType theMetadata;
            theMetadata = this.getMetadata();
            toStringBuilder.append("metadata", theMetadata);
        }
        {
            List<Object> theAny;
            theAny = this.getAny();
            toStringBuilder.append("any", theAny);
        }
    }

    public String toString() {
        final ToStringBuilder toStringBuilder = new JAXBToStringBuilder(this);
        toString(toStringBuilder);
        return toStringBuilder.toString();
    }

    public void equals(Object object, EqualsBuilder equalsBuilder) {
        if (!(object instanceof EndpointReferenceType)) {
            equalsBuilder.appendSuper(false);
            return ;
        }
        if (this == object) {
            return ;
        }
        final EndpointReferenceType that = ((EndpointReferenceType) object);
        equalsBuilder.append(this.getAddress(), that.getAddress());
        equalsBuilder.append(this.getReferenceParameters(), that.getReferenceParameters());
        equalsBuilder.append(this.getMetadata(), that.getMetadata());
        equalsBuilder.append(this.getAny(), that.getAny());
    }

    public boolean equals(Object object) {
        if (!(object instanceof EndpointReferenceType)) {
            return false;
        }
        if (this == object) {
            return true;
        }
        final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder();
        equals(object, equalsBuilder);
        return equalsBuilder.isEquals();
    }

    public void hashCode(HashCodeBuilder hashCodeBuilder) {
        hashCodeBuilder.append(this.getAddress());
        hashCodeBuilder.append(this.getReferenceParameters());
        hashCodeBuilder.append(this.getMetadata());
        hashCodeBuilder.append(this.getAny());
    }

    public int hashCode() {
        final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
        hashCode(hashCodeBuilder);
        return hashCodeBuilder.toHashCode();
    }

    /**
     * Gets the value of the hjid property.
     *
     * @return
     *     possible object is
     *     {@link Long }
     *
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "HJID")
    public Long getHjid() {
        return hjid;
    }

    /**
     * Sets the value of the hjid property.
     *
     * @param value
     *     allowed object is
     *     {@link Long }
     *
     */
    public void setHjid(Long value) {
        this.hjid = value;
    }

    @OneToMany(cascade = {
        CascadeType.ALL
    })
    @JoinTable(name = "ENDPOINTREFERENCETYPE_ANYITE_0", joinColumns = {
        @JoinColumn(name = "PARENT_ENDPOINTREFERENCETYPE_0")
    }, inverseJoinColumns = {
        @JoinColumn(name = "CHILD_ENDPOINTREFERENCETYPEA_0")
    })
    @OrderBy
    public List<EndpointReferenceType.AnyItem> getAnyItems() {
        if (this.anyItems == null) {
            this.anyItems = new ArrayList<EndpointReferenceType.AnyItem>();
        }
        if (ItemUtils.shouldBeWrapped(this.any)) {
            this.any = ItemUtils.wrap(this.any, this.anyItems, EndpointReferenceType.AnyItem.class);
        }
        return this.anyItems;
    }

    public void setAnyItems(List<EndpointReferenceType.AnyItem> value) {
        this.any = null;
        this.anyItems = null;
        this.anyItems = value;
        if (this.anyItems == null) {
            this.anyItems = new ArrayList<EndpointReferenceType.AnyItem>();
        }
        if (ItemUtils.shouldBeWrapped(this.any)) {
            this.any = ItemUtils.wrap(this.any, this.anyItems, EndpointReferenceType.AnyItem.class);
        }
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @Entity(name = "org.w3._2005._08.addressing.EndpointReferenceType$AnyItem")
    @Table(name = "ENDPOINTREFERENCETYPEANYITEM")
    @Inheritance(strategy = InheritanceType.JOINED)
    public static class AnyItem
        implements Item<Object>
    {

        @XmlAnyElement(lax = true)
        protected Object item;
        @XmlAttribute
        protected Long hjid;

        /**
         *
         *
         * @return
         *     possible object is
         *     {@link Element }
         *     {@link Object }
         *
         */
        @Transient
        public Object getItem() {
            return item;
        }

        /**
         *
         *
         * @param value
         *     allowed object is
         *     {@link Element }
         *     {@link Object }
         *
         */
        public void setItem(Object value) {
            this.item = value;
        }

        /**
         * Gets the value of the hjid property.
         *
         * @return
         *     possible object is
         *     {@link Long }
         *
         */
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "HJID")
        public Long getHjid() {
            return hjid;
        }

        /**
         * Sets the value of the hjid property.
         *
         * @param value
         *     allowed object is
         *     {@link Long }
         *
         */
        public void setHjid(Long value) {
            this.hjid = value;
        }

        @Basic
        @Lob
        @Column(name = "ITEMELEMENT")
        public String getItemElement() {
            if (this.getItem() instanceof Element) {
                return XmlAdapterUtils.unmarshall(ElementAsString.class, ((Element) this.getItem()));
            } else {
                return null;
            }
        }

        public void setItemElement(String target) {
            if (target!= null) {
                setItem(XmlAdapterUtils.marshall(ElementAsString.class, target));
            }
        }

        @Basic
        @Lob
        @Column(name = "ITEMOBJECT")
        public String getItemObject() {
            if (JAXBContextUtils.isElement("org.w3._2005._08.addressing", this.getItem())) {
                return JAXBContextUtils.unmarshall("org.w3._2005._08.addressing", this.getItem());
            } else {
                return null;
            }
        }

        public void setItemObject(String target) {
            if (target!= null) {
                setItem(JAXBContextUtils.marshall("org.w3._2005._08.addressing", target));
            }
        }

    }

}
