|  1 |     | 
   package org.kuali.rice.krms.api.repository.type;  | 
  |  2 |     | 
     | 
  |  3 |     | 
   import java.io.Serializable;  | 
  |  4 |     | 
   import java.util.Collection;  | 
  |  5 |     | 
     | 
  |  6 |     | 
   import javax.xml.bind.annotation.XmlAccessType;  | 
  |  7 |     | 
   import javax.xml.bind.annotation.XmlAccessorType;  | 
  |  8 |     | 
   import javax.xml.bind.annotation.XmlAnyElement;  | 
  |  9 |     | 
   import javax.xml.bind.annotation.XmlElement;  | 
  |  10 |     | 
   import javax.xml.bind.annotation.XmlRootElement;  | 
  |  11 |     | 
   import javax.xml.bind.annotation.XmlType;  | 
  |  12 |     | 
     | 
  |  13 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  14 |     | 
   import org.apache.commons.lang.builder.EqualsBuilder;  | 
  |  15 |     | 
   import org.apache.commons.lang.builder.HashCodeBuilder;  | 
  |  16 |     | 
   import org.apache.commons.lang.builder.ToStringBuilder;  | 
  |  17 |     | 
   import org.kuali.rice.core.api.CoreConstants;  | 
  |  18 |     | 
   import org.kuali.rice.core.api.mo.ModelBuilder;  | 
  |  19 |     | 
   import org.kuali.rice.core.api.mo.ModelObjectComplete;  | 
  |  20 |     | 
   import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition.Builder;  | 
  |  21 |     | 
     | 
  |  22 |     | 
     | 
  |  23 |     | 
     | 
  |  24 |     | 
     | 
  |  25 |     | 
     | 
  |  26 |     | 
     | 
  |  27 |     | 
     | 
  |  28 |    1 |    @XmlRootElement(name = KrmsTypeAttribute.Constants.ROOT_ELEMENT_NAME)  | 
  |  29 |     | 
   @XmlAccessorType(XmlAccessType.NONE)  | 
  |  30 |     | 
   @XmlType(name = KrmsTypeAttribute.Constants.TYPE_NAME, propOrder = { | 
  |  31 |     | 
                   KrmsTypeAttribute.Elements.ID,  | 
  |  32 |     | 
                   KrmsTypeAttribute.Elements.TYPE_ID,  | 
  |  33 |     | 
                   KrmsTypeAttribute.Elements.ATTR_DEFN_ID,  | 
  |  34 |     | 
                   KrmsTypeAttribute.Elements.SEQ_NO,  | 
  |  35 |     | 
                   KrmsTypeAttribute.Elements.ACTIVE,  | 
  |  36 |     | 
                   KrmsTypeAttribute.Elements.ATTR_DEFN,  | 
  |  37 |     | 
                   CoreConstants.CommonElements.FUTURE_ELEMENTS  | 
  |  38 |     | 
   })  | 
  |  39 |    9 |    public final class KrmsTypeAttribute implements KrmsTypeAttributeContract, ModelObjectComplete{ | 
  |  40 |     | 
           private static final long serialVersionUID = -304265575559412478L;  | 
  |  41 |     | 
             | 
  |  42 |     | 
           @XmlElement(name = Elements.ID, required=true)  | 
  |  43 |     | 
           private String id;  | 
  |  44 |     | 
           @XmlElement(name = Elements.TYPE_ID, required=true)  | 
  |  45 |     | 
           private String typeId;  | 
  |  46 |     | 
           @XmlElement(name = Elements.ATTR_DEFN_ID, required=true)  | 
  |  47 |     | 
           private String attributeDefinitionId;  | 
  |  48 |     | 
           @XmlElement(name = Elements.SEQ_NO, required=true)  | 
  |  49 |     | 
           private Integer sequenceNumber;  | 
  |  50 |     | 
           @XmlElement(name = Elements.ACTIVE, required=false)  | 
  |  51 |     | 
           private boolean active;  | 
  |  52 |     | 
           @XmlElement(name = Elements.ATTR_DEFN, required=false)  | 
  |  53 |     | 
           private KrmsAttributeDefinition attributeDefinition;  | 
  |  54 |     | 
             | 
  |  55 |    20 |            @SuppressWarnings("unused") | 
  |  56 |     | 
       @XmlAnyElement  | 
  |  57 |     | 
       private final Collection<org.w3c.dom.Element> _futureElements = null;  | 
  |  58 |     | 
             | 
  |  59 |     | 
              | 
  |  60 |     | 
     | 
  |  61 |     | 
     | 
  |  62 |    11 |        private KrmsTypeAttribute() { | 
  |  63 |    11 |                this.id = null;  | 
  |  64 |    11 |                this.typeId = null;  | 
  |  65 |    11 |                this.attributeDefinitionId = null;  | 
  |  66 |    11 |                this.sequenceNumber = null;  | 
  |  67 |    11 |                this.active = false;  | 
  |  68 |    11 |                this.attributeDefinition = null;  | 
  |  69 |    11 |        }  | 
  |  70 |     | 
         | 
  |  71 |     | 
         | 
  |  72 |     | 
     | 
  |  73 |     | 
     | 
  |  74 |     | 
     | 
  |  75 |     | 
     | 
  |  76 |     | 
     | 
  |  77 |    9 |        private KrmsTypeAttribute(Builder builder) { | 
  |  78 |    9 |            this.id = builder.getId();  | 
  |  79 |    9 |            this.typeId = builder.getTypeId();  | 
  |  80 |    9 |            this.attributeDefinitionId = builder.getAttributeDefinitionId();  | 
  |  81 |    9 |            this.sequenceNumber = builder.getSequenceNumber();  | 
  |  82 |    9 |            this.active = builder.isActive();  | 
  |  83 |    9 |            if (builder.getAttributeDefinition() != null) { | 
  |  84 |    2 |                    this.attributeDefinition = builder.getAttributeDefinition().build();  | 
  |  85 |     | 
           }  | 
  |  86 |    9 |        }  | 
  |  87 |     | 
         | 
  |  88 |     | 
           public String getId() { | 
  |  89 |    3 |                    return this.id;  | 
  |  90 |     | 
           }  | 
  |  91 |     | 
             | 
  |  92 |     | 
           public String getTypeId() { | 
  |  93 |    3 |                    return this.typeId;  | 
  |  94 |     | 
           }  | 
  |  95 |     | 
     | 
  |  96 |     | 
           public String getAttributeDefinitionId() { | 
  |  97 |    3 |                    return this.attributeDefinitionId;  | 
  |  98 |     | 
           }  | 
  |  99 |     | 
     | 
  |  100 |     | 
           public Integer getSequenceNumber() { | 
  |  101 |    3 |                    return this.sequenceNumber;  | 
  |  102 |     | 
           }  | 
  |  103 |     | 
             | 
  |  104 |     | 
           public boolean isActive() { | 
  |  105 |    4 |                    return this.active;   | 
  |  106 |     | 
           }  | 
  |  107 |     | 
     | 
  |  108 |     | 
           public KrmsAttributeDefinition getAttributeDefinition() { | 
  |  109 |    1 |                    return this.attributeDefinition;  | 
  |  110 |     | 
           }  | 
  |  111 |     | 
             | 
  |  112 |     | 
             | 
  |  113 |     | 
     | 
  |  114 |     | 
     | 
  |  115 |    5 |        public static class Builder implements KrmsTypeAttributeContract, ModelBuilder, Serializable { | 
  |  116 |     | 
                   private static final long serialVersionUID = 2729964674427296346L;  | 
  |  117 |     | 
     | 
  |  118 |     | 
                   private String id;  | 
  |  119 |     | 
           private String typeId;  | 
  |  120 |     | 
           private String attributeDefinitionId;  | 
  |  121 |     | 
           private Integer sequenceNumber;  | 
  |  122 |     | 
           private boolean active;  | 
  |  123 |     | 
           private KrmsAttributeDefinition.Builder attributeDefinition;  | 
  |  124 |     | 
     | 
  |  125 |     | 
                     | 
  |  126 |     | 
     | 
  |  127 |     | 
     | 
  |  128 |    21 |            private Builder(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { | 
  |  129 |    21 |                setId(id);  | 
  |  130 |    19 |                setTypeId(typeId);  | 
  |  131 |    17 |                setAttributeDefinitionId(attributeDefinitionId);  | 
  |  132 |    13 |                setSequenceNumber(sequenceNumber);  | 
  |  133 |    12 |                            setActive(true);  | 
  |  134 |    12 |            }  | 
  |  135 |     | 
     | 
  |  136 |     | 
           public Builder attributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition){ | 
  |  137 |    2 |                    setAttributeDefinition(attributeDefinition);  | 
  |  138 |    2 |                    return this;  | 
  |  139 |     | 
           }  | 
  |  140 |     | 
             | 
  |  141 |     | 
             | 
  |  142 |     | 
     | 
  |  143 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |     | 
     | 
  |  147 |     | 
     | 
  |  148 |     | 
     | 
  |  149 |     | 
     | 
  |  150 |     | 
     | 
  |  151 |     | 
           public static Builder create(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { | 
  |  152 |    21 |                return new Builder(id, typeId, attributeDefinitionId, sequenceNumber);  | 
  |  153 |     | 
           }  | 
  |  154 |     | 
             | 
  |  155 |     | 
           public static Builder create(KrmsTypeAttributeContract contract){ | 
  |  156 |    0 |                    if (contract == null) { | 
  |  157 |    0 |                    throw new IllegalArgumentException("contract is null"); | 
  |  158 |     | 
               }  | 
  |  159 |    0 |                    Builder builder = new Builder(contract.getId(),   | 
  |  160 |     | 
                                   contract.getTypeId(),  | 
  |  161 |     | 
                                   contract.getAttributeDefinitionId(),  | 
  |  162 |     | 
                                   contract.getSequenceNumber());  | 
  |  163 |    0 |                    if (contract.getAttributeDefinition() != null){ | 
  |  164 |    0 |                            KrmsAttributeDefinition.Builder attrBuilder =   | 
  |  165 |     | 
                                   KrmsAttributeDefinition.Builder.create(contract.getAttributeDefinition());  | 
  |  166 |    0 |                            builder.setAttributeDefinition(attrBuilder);  | 
  |  167 |     | 
                   }  | 
  |  168 |    0 |                    return builder;  | 
  |  169 |     | 
           }  | 
  |  170 |     | 
     | 
  |  171 |     | 
                     | 
  |  172 |     | 
     | 
  |  173 |     | 
     | 
  |  174 |     | 
     | 
  |  175 |     | 
     | 
  |  176 |     | 
     | 
  |  177 |     | 
           public void setId(String id) { | 
  |  178 |    21 |                if (null != id && StringUtils.isBlank(id)) { | 
  |  179 |    2 |                    throw new IllegalArgumentException("id must be null or non-blank"); | 
  |  180 |     | 
               }  | 
  |  181 |    19 |                this.id = id;  | 
  |  182 |    19 |            }  | 
  |  183 |     | 
     | 
  |  184 |     | 
                   public void setTypeId(String typeId) { | 
  |  185 |    19 |                if (null != typeId && StringUtils.isBlank(typeId)) { | 
  |  186 |    2 |                    throw new IllegalArgumentException("typeId must be null or non-blank"); | 
  |  187 |     | 
               }  | 
  |  188 |    17 |                            this.typeId = typeId;  | 
  |  189 |    17 |                    }  | 
  |  190 |     | 
     | 
  |  191 |     | 
                   public void setAttributeDefinitionId(String attributeDefinitionId) { | 
  |  192 |    17 |                if (StringUtils.isBlank(attributeDefinitionId)) { | 
  |  193 |    4 |                    throw new IllegalArgumentException("the attribute definition id is blank"); | 
  |  194 |     | 
               }  | 
  |  195 |    13 |                            this.attributeDefinitionId = attributeDefinitionId;  | 
  |  196 |    13 |                    }  | 
  |  197 |     | 
                     | 
  |  198 |     | 
                   public void setSequenceNumber(Integer sequenceNumber) { | 
  |  199 |    13 |                            if (sequenceNumber == null){ | 
  |  200 |    1 |                                     throw new IllegalArgumentException("the sequence number is null"); | 
  |  201 |     | 
                           }  | 
  |  202 |    12 |                            this.sequenceNumber = sequenceNumber;  | 
  |  203 |    12 |                    }  | 
  |  204 |     | 
                     | 
  |  205 |     | 
                   public void setAttributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition) { | 
  |  206 |    2 |                            this.attributeDefinition = attributeDefinition;  | 
  |  207 |     | 
                             | 
  |  208 |    2 |                    }  | 
  |  209 |     | 
                     | 
  |  210 |     | 
                   public void setActive(boolean active) { | 
  |  211 |    12 |                            this.active = active;  | 
  |  212 |    12 |                    }  | 
  |  213 |     | 
     | 
  |  214 |     | 
                   public String getId() { | 
  |  215 |    9 |                            return id;  | 
  |  216 |     | 
                   }  | 
  |  217 |     | 
     | 
  |  218 |     | 
                   public String getTypeId() { | 
  |  219 |    9 |                            return typeId;  | 
  |  220 |     | 
                   }  | 
  |  221 |     | 
     | 
  |  222 |     | 
                   public String getAttributeDefinitionId() { | 
  |  223 |    9 |                            return attributeDefinitionId;  | 
  |  224 |     | 
                   }  | 
  |  225 |     | 
                     | 
  |  226 |     | 
                   public Integer getSequenceNumber() { | 
  |  227 |    9 |                            return sequenceNumber;  | 
  |  228 |     | 
                   }  | 
  |  229 |     | 
     | 
  |  230 |     | 
                   public KrmsAttributeDefinition.Builder getAttributeDefinition() { | 
  |  231 |    11 |                            return attributeDefinition;  | 
  |  232 |     | 
                   }  | 
  |  233 |     | 
     | 
  |  234 |     | 
     | 
  |  235 |     | 
                   public boolean isActive() { | 
  |  236 |    9 |                            return active;  | 
  |  237 |     | 
                   }  | 
  |  238 |     | 
     | 
  |  239 |     | 
                     | 
  |  240 |     | 
     | 
  |  241 |     | 
     | 
  |  242 |     | 
     | 
  |  243 |     | 
     | 
  |  244 |     | 
           @Override  | 
  |  245 |     | 
           public KrmsTypeAttribute build() { | 
  |  246 |    9 |                return new KrmsTypeAttribute(this);  | 
  |  247 |     | 
           }  | 
  |  248 |     | 
                     | 
  |  249 |     | 
       }  | 
  |  250 |     | 
           @Override  | 
  |  251 |     | 
           public int hashCode() { | 
  |  252 |    0 |                    return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  253 |     | 
           }  | 
  |  254 |     | 
     | 
  |  255 |     | 
           @Override  | 
  |  256 |     | 
           public boolean equals(Object obj) { | 
  |  257 |    5 |                    return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  258 |     | 
           }  | 
  |  259 |     | 
     | 
  |  260 |     | 
           @Override  | 
  |  261 |     | 
           public String toString() { | 
  |  262 |    0 |                    return ToStringBuilder.reflectionToString(this);  | 
  |  263 |     | 
           }  | 
  |  264 |     | 
             | 
  |  265 |     | 
             | 
  |  266 |     | 
     | 
  |  267 |     | 
     | 
  |  268 |    0 |            static class Constants { | 
  |  269 |     | 
                   final static String ROOT_ELEMENT_NAME = "KrmsTypeAttribute";  | 
  |  270 |     | 
                   final static String TYPE_NAME = "KrmsTypeAttributeType";  | 
  |  271 |    1 |                    final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS }; | 
  |  272 |     | 
           }  | 
  |  273 |     | 
             | 
  |  274 |     | 
             | 
  |  275 |     | 
     | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |    0 |            public static class Elements { | 
  |  279 |     | 
                   final static String ID = "id";  | 
  |  280 |     | 
                   final static String TYPE_ID = "typeId";  | 
  |  281 |     | 
                   final static String ATTR_DEFN_ID = "attributeDefinitionId";  | 
  |  282 |     | 
                   final static String SEQ_NO = "sequenceNumber";  | 
  |  283 |     | 
                   final static String ACTIVE = "active";  | 
  |  284 |     | 
                   final static String ATTR_DEFN = "attributeDefinition";  | 
  |  285 |     | 
           }  | 
  |  286 |     | 
   }  |