Coverage Report - org.kuali.rice.kim.api.common.attribute.KimAttributeData
 
Classes in this File Line Coverage Branch Coverage Complexity
KimAttributeData
91%
31/34
50%
2/4
1.182
KimAttributeData$1
N/A
N/A
1.182
KimAttributeData$Builder
95%
41/43
50%
3/6
1.182
KimAttributeData$Constants
50%
1/2
N/A
1.182
KimAttributeData$Elements
0%
0/1
N/A
1.182
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.kim.api.common.attribute;
 18  
 
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.apache.commons.lang.builder.EqualsBuilder;
 21  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 22  
 import org.apache.commons.lang.builder.ToStringBuilder;
 23  
 import org.kuali.rice.core.api.CoreConstants;
 24  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 25  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 26  
 import org.kuali.rice.kim.api.type.KimType;
 27  
 import org.w3c.dom.Element;
 28  
 
 29  
 import javax.xml.bind.annotation.XmlAccessType;
 30  
 import javax.xml.bind.annotation.XmlAccessorType;
 31  
 import javax.xml.bind.annotation.XmlAnyElement;
 32  
 import javax.xml.bind.annotation.XmlElement;
 33  
 import javax.xml.bind.annotation.XmlRootElement;
 34  
 import javax.xml.bind.annotation.XmlType;
 35  
 import java.io.Serializable;
 36  
 import java.util.Collection;
 37  
 
 38  
 
 39  2
 @XmlRootElement(name = KimAttributeData.Constants.ROOT_ELEMENT_NAME)
 40  
 @XmlAccessorType(XmlAccessType.NONE)
 41  
 @XmlType(name = KimAttributeData.Constants.TYPE_NAME, propOrder = {
 42  
         KimAttributeData.Elements.ID,
 43  
         KimAttributeData.Elements.ASSIGNED_TO_ID,
 44  
         KimAttributeData.Elements.KIM_TYPE_ID,
 45  
         KimAttributeData.Elements.KIM_TYPE,
 46  
         KimAttributeData.Elements.KIM_ATTRIBUTE,
 47  
         KimAttributeData.Elements.ATTRIBUTE_VALUE,
 48  
         CoreConstants.CommonElements.VERSION_NUMBER,
 49  
         CoreConstants.CommonElements.OBJECT_ID,
 50  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 51  
 })
 52  1
 public final class KimAttributeData implements KimAttributeDataContract, ModelObjectComplete {
 53  
     @XmlElement(name = Elements.ID, required = false)
 54  
     private final String id;
 55  
 
 56  
     @XmlElement(name = Elements.ASSIGNED_TO_ID, required = false)
 57  
     private final String assignedToId;
 58  
 
 59  
     @XmlElement(name = Elements.KIM_TYPE_ID, required = true)
 60  
     private final String kimTypeId;
 61  
 
 62  
     @XmlElement(name = Elements.KIM_TYPE, required = false)
 63  
     private final KimType kimType;
 64  
 
 65  
     @XmlElement(name = Elements.KIM_ATTRIBUTE, required = false)
 66  
     private final KimAttribute kimAttribute;
 67  
 
 68  
     @XmlElement(name = Elements.ATTRIBUTE_VALUE, required = false)
 69  
     private final String attributeValue;
 70  
 
 71  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 72  
     private final Long versionNumber;
 73  
 
 74  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 75  
     private final String objectId;
 76  
 
 77  4
     @SuppressWarnings("unused")
 78  
     @XmlAnyElement
 79  
     private final Collection<Element> _futureElements = null;
 80  
 
 81  
     @SuppressWarnings("unused")
 82  3
     private KimAttributeData() {
 83  3
         this.id = null;
 84  3
         this.assignedToId = null;
 85  3
         this.kimTypeId = null;
 86  3
         this.kimType = null;
 87  3
         this.kimAttribute = null;
 88  3
         this.attributeValue = null;
 89  3
         this.versionNumber = null;
 90  3
         this.objectId = null;
 91  3
     }
 92  
 
 93  1
     private KimAttributeData(Builder builder) {
 94  1
         this.id = builder.getId();
 95  1
         this.assignedToId = builder.getAssignedToId();
 96  1
         this.kimTypeId = builder.getKimTypeId();
 97  1
         this.kimType =
 98  
                 builder.getKimType() != null ? builder.getKimType().build() : null;
 99  1
         this.kimAttribute =
 100  
                 builder.getKimAttribute() != null ? builder.getKimAttribute().build() : null;
 101  1
         this.attributeValue = builder.getAttributeValue();
 102  1
         this.versionNumber = builder.getVersionNumber();
 103  1
         this.objectId = builder.getObjectId();
 104  1
     }
 105  
 
 106  
     @Override
 107  
     public String getId() {
 108  1
         return id;
 109  
     }
 110  
 
 111  
     @Override
 112  
     public String getAssignedToId() {
 113  1
         return assignedToId;
 114  
     }
 115  
 
 116  
     @Override
 117  
     public String getKimTypeId() {
 118  0
         return kimTypeId;
 119  
     }
 120  
 
 121  
     @Override
 122  
     public KimType getKimType() {
 123  1
         return kimType;
 124  
     }
 125  
 
 126  
     @Override
 127  
     public KimAttribute getKimAttribute() {
 128  1
         return kimAttribute;
 129  
     }
 130  
 
 131  
     @Override
 132  
     public String getAttributeValue() {
 133  1
         return attributeValue;
 134  
     }
 135  
 
 136  
     @Override
 137  
     public Long getVersionNumber() {
 138  1
         return versionNumber;
 139  
     }
 140  
 
 141  
     @Override
 142  
     public String getObjectId() {
 143  1
         return objectId;
 144  
     }
 145  
 
 146  
     @Override
 147  
     public int hashCode() {
 148  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 149  
     }
 150  
 
 151  
     @Override
 152  
     public boolean equals(Object obj) {
 153  1
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 154  
     }
 155  
 
 156  
     @Override
 157  
     public String toString() {
 158  0
         return ToStringBuilder.reflectionToString(this);
 159  
     }
 160  
 
 161  1
     public static final class Builder implements KimAttributeDataContract, ModelBuilder, Serializable {
 162  
         private String id;
 163  
         private String assignedToId;
 164  
         private String kimTypeId;
 165  
         private KimType.Builder kimType;
 166  
         private KimAttribute.Builder kimAttribute;
 167  
         private String attributeValue;
 168  
         private Long versionNumber;
 169  
         private String objectId;
 170  
 
 171  1
         private Builder(String kimTypeId) {
 172  1
             setKimTypeId(kimTypeId);
 173  1
         }
 174  
 
 175  
         /**
 176  
          * creates a Parameter with the required fields.
 177  
          */
 178  
         public static Builder create(String kimTypeId) {
 179  0
             return new Builder(kimTypeId);
 180  
         }
 181  
 
 182  
         /**
 183  
          * creates a KimAttributeData from an existing {@link org.kuali.rice.kim.api.common.attribute.KimAttributeContract}
 184  
          */
 185  
         public static Builder create(KimAttributeDataContract contract) {
 186  1
             Builder builder = new Builder(contract.getKimTypeId());
 187  1
             builder.setAssignedToId(contract.getAssignedToId());
 188  
 
 189  1
             builder.setId(contract.getId());
 190  1
             if (contract.getKimAttribute() != null) {
 191  1
                 builder.setKimAttribute(KimAttribute.Builder.create(contract.getKimAttribute()));
 192  
             }
 193  1
             if (contract.getKimType() != null) {
 194  1
                 builder.setKimType(KimType.Builder.create(contract.getKimType()));
 195  
             }
 196  1
             builder.setValue(contract.getAttributeValue());
 197  1
             builder.setVersionNumber(contract.getVersionNumber());
 198  1
             builder.setObjectId(contract.getObjectId());
 199  1
             return builder;
 200  
         }
 201  
 
 202  
         @Override
 203  
         public String getId() {
 204  1
             return id;
 205  
         }
 206  
 
 207  
         public void setId(final String id) {
 208  1
             if (StringUtils.isWhitespace(id)) {
 209  0
                 throw new IllegalArgumentException("id is blank");
 210  
             }
 211  1
             this.id = id;
 212  1
         }
 213  
 
 214  
         @Override
 215  
         public String getAssignedToId() {
 216  1
             return assignedToId;
 217  
         }
 218  
 
 219  
         public void setAssignedToId(final String assignedToId) {
 220  1
             this.assignedToId = assignedToId;
 221  1
         }
 222  
 
 223  
         @Override
 224  
         public String getKimTypeId(){
 225  1
             return kimTypeId;
 226  
         }
 227  
 
 228  
         public void setKimTypeId(String kimTypeId) {
 229  1
             this.kimTypeId = kimTypeId;
 230  1
         }
 231  
 
 232  
         @Override
 233  
         public KimType.Builder getKimType() {
 234  2
             return kimType;
 235  
         }
 236  
 
 237  
         public void setKimType(final KimType.Builder kimType) {
 238  1
             this.kimType = kimType;
 239  1
         }
 240  
 
 241  
         @Override
 242  
         public KimAttribute.Builder getKimAttribute() {
 243  2
             return kimAttribute;
 244  
         }
 245  
 
 246  
         public void setKimAttribute(final KimAttribute.Builder kimAttribute) {
 247  1
             this.kimAttribute = kimAttribute;
 248  1
         }
 249  
 
 250  
         @Override
 251  
         public String getAttributeValue() {
 252  1
             return attributeValue;
 253  
         }
 254  
 
 255  
         public void setValue(final String attributeValue) {
 256  1
             this.attributeValue = attributeValue;
 257  1
         }
 258  
 
 259  
         @Override
 260  
         public Long getVersionNumber() {
 261  1
             return versionNumber;
 262  
         }
 263  
 
 264  
         public void setVersionNumber(Long versionNumber) {
 265  1
             this.versionNumber = versionNumber;
 266  1
         }
 267  
 
 268  
         @Override
 269  
         public String getObjectId() {
 270  1
             return objectId;
 271  
         }
 272  
 
 273  
         public void setObjectId(final String objectId) {
 274  1
             this.objectId = objectId;
 275  1
         }
 276  
 
 277  
         @Override
 278  
         public KimAttributeData build() {
 279  1
             return new KimAttributeData(this);
 280  
         }
 281  
     }
 282  
 
 283  
     /**
 284  
      * Defines some internal constants used on this class.
 285  
      */
 286  0
     static class Constants {
 287  
         final static String ROOT_ELEMENT_NAME = "kimAttributeData";
 288  
         final static String TYPE_NAME = "KimAttributeDataType";
 289  1
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 290  
     }
 291  
 
 292  
     /**
 293  
      * A private class which exposes constants which define the XML element names to use
 294  
      * when this object is marshalled to XML.
 295  
      */
 296  0
     static class Elements {
 297  
         final static String ID = "id";
 298  
         final static String ASSIGNED_TO_ID = "assignedToId";
 299  
         final static String KIM_TYPE_ID = "kimTypeId";
 300  
         final static String KIM_TYPE = "kimType";
 301  
         final static String KIM_ATTRIBUTE = "kimAttribute";
 302  
         final static String ATTRIBUTE_VALUE = "attributeValue";
 303  
     }
 304  
 }