package gov.nih.nci.iso21090;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.list.PredicatedList;

/**
 * Represents the En ISO datatype.
 * @author lpower
 */
public class En extends Any implements Cloneable {

    private static final long serialVersionUID = 2L;

    private transient List<Enxp> part;
    private final List<Enxp> partsInternal;
    private Predicate partRestriction;
    private Set<EntityNameUse> use;

    /**
     * @return the use
     */
    public Set<EntityNameUse> getUse() {
        return use;
    }

    /**
     * @param use the use to set
     */
    public void setUse(Set<EntityNameUse> use) {
        this.use = use;
    }

    /**
     * Default constructor.
     */
    public En() {
        partsInternal = new ArrayList<Enxp>();
    }

    /**
     * @param partRestriction a filter for disallowed values
     */
    protected En(Predicate partRestriction) {
        this();
        this.partRestriction = partRestriction;
    }

    /**
     * @return the part
     */
    @SuppressWarnings("unchecked")
    public List<Enxp> getPart() {
        if (part == null) {
            if (partRestriction != null) {
                part = PredicatedList.decorate(partsInternal, partRestriction);
            } else {
                part = partsInternal;
            }
        }
        return part;
    }

    /**
     * @param part the part list to set
     */
    public void setPart(List<Enxp> part) {
        this.getPart().clear();
        for (Enxp tempPart : part) {
            this.getPart().add(tempPart);
    }
    }

    /**
     * @param partInstance ENXP instance to be added to part collection
     */
    public void addPart(Enxp partInstance) {
        if (partInstance != null) {
            getPart().add(partInstance);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        if (this == obj) {
            return true;
        }

        if (!(obj instanceof En)) {
            return false;
        }

        En x = (En) obj;

        return super.equals(obj) && this.getPart().equals(x.getPart());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        if (!this.getPart().isEmpty()) {
            return this.getPart().hashCode();
        }
        return super.hashCode();
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("PMD.CloneThrowsCloneNotSupportedException")
    @Override
    public En clone() {
        return (En) super.clone();
    }
}

@@ -390,18 +390,8 @@
 ate 
-transient 
 List
@@ -442,24 +442,28 @@
 rtsInternal;
+    
 %0A    private
@@ -1435,32 +1435,36 @@
 urn part;%0A    %7D%0A
+    
 %0A    /**%0A     * 
@@ -1564,119 +1564,28 @@
 his.
-getPart().clear();%0A        for (Enxp tempP
+p
 art 
-:
+=
  part
-) %7B%0A            this.getPart().add(tempPart);%0A    %7D
+;
 %0A    %7D%0A%0A
     
@@ -1572,32 +1572,33 @@
  = part;%0A    %7D%0A%0A
+%0A
     /**%0A     * @
@@ -1621,24 +1621,20 @@
 ce ENXP 
-instance
+part
  to be a
@@ -1641,16 +1641,20 @@
 dded to 
+the 
 part col
@@ -1710,24 +1710,104 @@
 Instance) %7B%0A
+        if (part == null) %7B%0A            part = new ArrayList%3CEnxp%3E();%0A        %7D%0A
         if (
@@ -1842,25 +1842,20 @@
         
-getP
+p
 art
-()
 .add(par

Fix for [#29809] Incorrect QBE search for EN datatype