/*******************************************************************************
 * Copyright (c) 2013, SAP AG
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 *  
 *     - Redistributions of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 *     - Redistributions in binary form must reproduce the above copyright 
 *      notice, this list of conditions and the following disclaimer in the 
 *      documentation and/or other materials provided with the distribution.
 *     - Neither the name of the SAP AG nor the names of its contributors may
 *      be used to endorse or promote products derived from this software 
 *      without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
 * THE POSSIBILITY OF SUCH DAMAGE.
 ******************************************************************************/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v3.0-03/04/2009 09:20 AM(valikov)-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: 2010.11.03 at 09:58:45 AM CET 
//


package eu.primelife.ppl.policy.xacml.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
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.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
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.ItemUtils;
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;


/**
 * <p>Java class for PolicySetType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="PolicySetType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}Description" minOccurs="0"/>
 *         &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicySetDefaults" minOccurs="0"/>
 *         &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}Target"/>
 *         &lt;choice maxOccurs="unbounded" minOccurs="0">
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicySet"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}Policy"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicySetIdReference"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicyIdReference"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}CombinerParameters"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicyCombinerParameters"/>
 *           &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}PolicySetCombinerParameters"/>
 *         &lt;/choice>
 *         &lt;element ref="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}Obligations" minOccurs="0"/>
 *       &lt;/sequence>
 *       &lt;attribute name="PolicySetId" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *       &lt;attribute name="Version" type="{urn:oasis:names:tc:xacml:2.0:policy:schema:os}VersionType" default="1.0" />
 *       &lt;attribute name="PolicyCombiningAlgId" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PolicySetType", propOrder = {
    "description",
    "policySetDefaults",
    "target",
    "policySetOrPolicyOrPolicySetIdReference",
    "obligations"
})
@XmlSeeAlso({
    eu.primelife.ppl.policy.impl.PolicySetType.class
})
@Entity(name = "eu.primelife.ppl.policy.xacml.impl.PolicySetType")
@Table(name = "POLICYSETTYPE_0")
@Inheritance(strategy = InheritanceType.JOINED)
public class PolicySetType implements Serializable, Equals, HashCode, ToString
{

    @XmlElement(name = "Description")
    protected String description;
    @XmlElement(name = "PolicySetDefaults")
    protected DefaultsType policySetDefaults;
    @XmlElement(name = "Target", required = true)
    protected TargetType target;
    @XmlElementRefs({
        @XmlElementRef(name = "PolicyCombinerParameters", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "PolicyIdReference", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "PolicySetCombinerParameters", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "Policy", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "CombinerParameters", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "PolicySetIdReference", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class),
        @XmlElementRef(name = "PolicySet", namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", type = JAXBElement.class)
    })
    protected List<JAXBElement<?>> policySetOrPolicyOrPolicySetIdReference;
    @XmlElement(name = "Obligations")
    protected ObligationsType obligations;
    @XmlAttribute(name = "PolicySetId", required = true)
    @XmlSchemaType(name = "anyURI")
    protected String policySetId;
    @XmlAttribute(name = "Version")
    protected String version;
    @XmlAttribute(name = "PolicyCombiningAlgId", required = true)
    @XmlSchemaType(name = "anyURI")
    protected String policyCombiningAlgId;
    @XmlAttribute(name = "Hjid")
    protected Long hjid;
    protected transient List<PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem> policySetOrPolicyOrPolicySetIdReferenceItems;

    /**
     * Gets the value of the description property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Basic
    @Column(name = "DESCRIPTION", length = 255)
    public String getDescription() {
        return description;
    }

    /**
     * Sets the value of the description property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDescription(String value) {
        this.description = value;
    }

    /**
     * Gets the value of the policySetDefaults property.
     * 
     * @return
     *     possible object is
     *     {@link DefaultsType }
     *     
     */
    @ManyToOne(targetEntity = DefaultsType.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "POLICYSETDEFAULTS_POLICYSETT_0")
    public DefaultsType getPolicySetDefaults() {
        return policySetDefaults;
    }

    /**
     * Sets the value of the policySetDefaults property.
     * 
     * @param value
     *     allowed object is
     *     {@link DefaultsType }
     *     
     */
    public void setPolicySetDefaults(DefaultsType value) {
        this.policySetDefaults = value;
    }

    /**
     * Gets the value of the target property.
     * 
     * @return
     *     possible object is
     *     {@link TargetType }
     *     
     */
    @ManyToOne(targetEntity = TargetType.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "TARGET_POLICYSETTYPE_0_HJID")
    public TargetType getTarget() {
        return target;
    }

    /**
     * Sets the value of the target property.
     * 
     * @param value
     *     allowed object is
     *     {@link TargetType }
     *     
     */
    public void setTarget(TargetType value) {
        this.target = value;
    }

    /**
     * Gets the value of the policySetOrPolicyOrPolicySetIdReference 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 policySetOrPolicyOrPolicySetIdReference property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getPolicySetOrPolicyOrPolicySetIdReference().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link JAXBElement }{@code <}{@link PolicyCombinerParametersType }{@code >}
     * {@link JAXBElement }{@code <}{@link IdReferenceType }{@code >}
     * {@link JAXBElement }{@code <}{@link PolicySetCombinerParametersType }{@code >}
     * {@link JAXBElement }{@code <}{@link eu.primelife.ppl.policy.xacml.impl.PolicyType }{@code >}
     * {@link JAXBElement }{@code <}{@link eu.primelife.ppl.policy.impl.PolicyType }{@code >}
     * {@link JAXBElement }{@code <}{@link CombinerParametersType }{@code >}
     * {@link JAXBElement }{@code <}{@link IdReferenceType }{@code >}
     * {@link JAXBElement }{@code <}{@link eu.primelife.ppl.policy.impl.PolicySetType }{@code >}
     * {@link JAXBElement }{@code <}{@link PolicySetType }{@code >}
     * 
     * 
     */
    @Transient
    public List<JAXBElement<?>> getPolicySetOrPolicyOrPolicySetIdReference() {
        if (policySetOrPolicyOrPolicySetIdReference == null) {
            policySetOrPolicyOrPolicySetIdReference = new ArrayList<JAXBElement<?>>();
        }
        return this.policySetOrPolicyOrPolicySetIdReference;
    }

    /**
     * 
     * 
     */
    public void setPolicySetOrPolicyOrPolicySetIdReference(List<JAXBElement<?>> policySetOrPolicyOrPolicySetIdReference) {
        this.policySetOrPolicyOrPolicySetIdReference = policySetOrPolicyOrPolicySetIdReference;
    }

    /**
     * Gets the value of the obligations property.
     * 
     * @return
     *     possible object is
     *     {@link ObligationsType }
     *     
     */
    @ManyToOne(targetEntity = ObligationsType.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "OBLIGATIONS_POLICYSETTYPE_0__0")
    public ObligationsType getObligations() {
        return obligations;
    }

    /**
     * Sets the value of the obligations property.
     * 
     * @param value
     *     allowed object is
     *     {@link ObligationsType }
     *     
     */
    public void setObligations(ObligationsType value) {
        this.obligations = value;
    }

    /**
     * Gets the value of the policySetId property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Basic
    @Column(name = "POLICYSETID")
    public String getPolicySetId() {
        return policySetId;
    }

    /**
     * Sets the value of the policySetId property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPolicySetId(String value) {
        this.policySetId = value;
    }

    /**
     * Gets the value of the version property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Basic
    @Column(name = "VERSION_", length = 255)
    public String getVersion() {
        if (version == null) {
            return "1.0";
        } else {
            return version;
        }
    }

    /**
     * Sets the value of the version property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVersion(String value) {
        this.version = value;
    }

    /**
     * Gets the value of the policyCombiningAlgId property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Basic
    @Column(name = "POLICYCOMBININGALGID")
    public String getPolicyCombiningAlgId() {
        return policyCombiningAlgId;
    }

    /**
     * Sets the value of the policyCombiningAlgId property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPolicyCombiningAlgId(String value) {
        this.policyCombiningAlgId = value;
    }

    /**
     * Gets the value of the hjid property.
     * 
     * @return
     *     possible object is
     *     {@link Long }
     *     
     */
    @Id
    @Column(name = "HJID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    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(targetEntity = PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "POLICYSETORPOLICYORPOLICYSET_1")
    public List<PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem> getPolicySetOrPolicyOrPolicySetIdReferenceItems() {
        if (this.policySetOrPolicyOrPolicySetIdReferenceItems == null) {
            this.policySetOrPolicyOrPolicySetIdReferenceItems = new ArrayList<PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem>();
        }
        if (ItemUtils.shouldBeWrapped(this.policySetOrPolicyOrPolicySetIdReference)) {
            this.policySetOrPolicyOrPolicySetIdReference = ItemUtils.wrap(this.policySetOrPolicyOrPolicySetIdReference, this.policySetOrPolicyOrPolicySetIdReferenceItems, PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem.class);
        }
        return this.policySetOrPolicyOrPolicySetIdReferenceItems;
    }

    public void setPolicySetOrPolicyOrPolicySetIdReferenceItems(List<PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem> value) {
        this.policySetOrPolicyOrPolicySetIdReference = null;
        this.policySetOrPolicyOrPolicySetIdReferenceItems = null;
        this.policySetOrPolicyOrPolicySetIdReferenceItems = value;
        if (this.policySetOrPolicyOrPolicySetIdReferenceItems == null) {
            this.policySetOrPolicyOrPolicySetIdReferenceItems = new ArrayList<PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem>();
        }
        if (ItemUtils.shouldBeWrapped(this.policySetOrPolicyOrPolicySetIdReference)) {
            this.policySetOrPolicyOrPolicySetIdReference = ItemUtils.wrap(this.policySetOrPolicyOrPolicySetIdReference, this.policySetOrPolicyOrPolicySetIdReferenceItems, PolicySetTypePolicySetOrPolicyOrPolicySetIdReferenceItem.class);
        }
    }

    public void equals(Object object, EqualsBuilder equalsBuilder) {
        if (!(object instanceof PolicySetType)) {
            equalsBuilder.appendSuper(false);
            return ;
        }
        if (this == object) {
            return ;
        }
        final PolicySetType that = ((PolicySetType) object);
        equalsBuilder.append(this.getDescription(), that.getDescription());
        equalsBuilder.append(this.getPolicySetDefaults(), that.getPolicySetDefaults());
        equalsBuilder.append(this.getTarget(), that.getTarget());
        equalsBuilder.append(this.getPolicySetOrPolicyOrPolicySetIdReference(), that.getPolicySetOrPolicyOrPolicySetIdReference());
        equalsBuilder.append(this.getObligations(), that.getObligations());
        equalsBuilder.append(this.getPolicySetId(), that.getPolicySetId());
        equalsBuilder.append(this.getVersion(), that.getVersion());
        equalsBuilder.append(this.getPolicyCombiningAlgId(), that.getPolicyCombiningAlgId());
    }

    public boolean equals(Object object) {
        if (!(object instanceof PolicySetType)) {
            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.getDescription());
        hashCodeBuilder.append(this.getPolicySetDefaults());
        hashCodeBuilder.append(this.getTarget());
        hashCodeBuilder.append(this.getPolicySetOrPolicyOrPolicySetIdReference());
        hashCodeBuilder.append(this.getObligations());
        hashCodeBuilder.append(this.getPolicySetId());
        hashCodeBuilder.append(this.getVersion());
        hashCodeBuilder.append(this.getPolicyCombiningAlgId());
    }

    public int hashCode() {
        final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
        hashCode(hashCodeBuilder);
        return hashCodeBuilder.toHashCode();
    }

    public void toString(ToStringBuilder toStringBuilder) {
        {
            String theDescription;
            theDescription = this.getDescription();
            toStringBuilder.append("description", theDescription);
        }
        {
            DefaultsType thePolicySetDefaults;
            thePolicySetDefaults = this.getPolicySetDefaults();
            toStringBuilder.append("policySetDefaults", thePolicySetDefaults);
        }
        {
            TargetType theTarget;
            theTarget = this.getTarget();
            toStringBuilder.append("target", theTarget);
        }
        {
            List<JAXBElement<?>> thePolicySetOrPolicyOrPolicySetIdReference;
            thePolicySetOrPolicyOrPolicySetIdReference = this.getPolicySetOrPolicyOrPolicySetIdReference();
            toStringBuilder.append("policySetOrPolicyOrPolicySetIdReference", thePolicySetOrPolicyOrPolicySetIdReference);
        }
        {
            ObligationsType theObligations;
            theObligations = this.getObligations();
            toStringBuilder.append("obligations", theObligations);
        }
        {
            String thePolicySetId;
            thePolicySetId = this.getPolicySetId();
            toStringBuilder.append("policySetId", thePolicySetId);
        }
        {
            String theVersion;
            theVersion = this.getVersion();
            toStringBuilder.append("version", theVersion);
        }
        {
            String thePolicyCombiningAlgId;
            thePolicyCombiningAlgId = this.getPolicyCombiningAlgId();
            toStringBuilder.append("policyCombiningAlgId", thePolicyCombiningAlgId);
        }
    }

    public String toString() {
        final ToStringBuilder toStringBuilder = new JAXBToStringBuilder(this);
        toString(toStringBuilder);
        return toStringBuilder.toString();
    }

}
