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  3
     private KimAttributeData() {
 82  3
         this.id = null;
 83  3
         this.assignedToId = null;
 84  3
         this.kimTypeId = null;
 85  3
         this.kimType = null;
 86  3
         this.kimAttribute = null;
 87  3
         this.attributeValue = null;
 88  3
         this.versionNumber = null;
 89  3
         this.objectId = null;
 90  3
     }
 91  
 
 92  1
     private KimAttributeData(Builder builder) {
 93  1
         this.id = builder.getId();
 94  1
         this.assignedToId = builder.getAssignedToId();
 95  1
         this.kimTypeId = builder.getKimTypeId();
 96  1
         this.kimType =
 97  
                 builder.getKimType() != null ? builder.getKimType().build() : null;
 98  1
         this.kimAttribute =
 99  
                 builder.getKimAttribute() != null ? builder.getKimAttribute().build() : null;
 100  1
         this.attributeValue = builder.getAttributeValue();
 101  1
         this.versionNumber = builder.getVersionNumber();
 102  1
         this.objectId = builder.getObjectId();
 103  1
     }
 104  
 
 105  
     @Override
 106  
     public String getId() {
 107  1
         return id;
 108  
     }
 109  
 
 110  
     @Override
 111  
     public String getAssignedToId() {
 112  1
         return assignedToId;
 113  
     }
 114  
 
 115  
     @Override
 116  
     public String getKimTypeId() {
 117  0
         return kimTypeId;
 118  
     }
 119  
 
 120  
     @Override
 121  
     public KimType getKimType() {
 122  1
         return kimType;
 123  
     }
 124  
 
 125  
     @Override
 126  
     public KimAttribute getKimAttribute() {
 127  1
         return kimAttribute;
 128  
     }
 129  
 
 130  
     @Override
 131  
     public String getAttributeValue() {
 132  1
         return attributeValue;
 133  
     }
 134  
 
 135  
     @Override
 136  
     public Long getVersionNumber() {
 137  1
         return versionNumber;
 138  
     }
 139  
 
 140  
     @Override
 141  
     public String getObjectId() {
 142  1
         return objectId;
 143  
     }
 144  
 
 145  
     @Override
 146  
     public int hashCode() {
 147  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 148  
     }
 149  
 
 150  
     @Override
 151  
     public boolean equals(Object obj) {
 152  1
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 153  
     }
 154  
 
 155  
     @Override
 156  
     public String toString() {
 157  0
         return ToStringBuilder.reflectionToString(this);
 158  
     }
 159  
 
 160  1
     public static final class Builder implements KimAttributeDataContract, ModelBuilder, Serializable {
 161  
         private String id;
 162  
         private String assignedToId;
 163  
         private String kimTypeId;
 164  
         private KimType.Builder kimType;
 165  
         private KimAttribute.Builder kimAttribute;
 166  
         private String attributeValue;
 167  
         private Long versionNumber;
 168  
         private String objectId;
 169  
 
 170  1
         private Builder(String kimTypeId) {
 171  1
             setKimTypeId(kimTypeId);
 172  1
         }
 173  
 
 174  
         /**
 175  
          * creates a Parameter with the required fields.
 176  
          */
 177  
         public static Builder create(String kimTypeId) {
 178  0
             return new Builder(kimTypeId);
 179  
         }
 180  
 
 181  
         /**
 182  
          * creates a KimAttributeData from an existing {@link org.kuali.rice.kim.api.common.attribute.KimAttributeContract}
 183  
          */
 184  
         public static Builder create(KimAttributeDataContract contract) {
 185  1
             Builder builder = new Builder(contract.getKimTypeId());
 186  1
             builder.setAssignedToId(contract.getAssignedToId());
 187  
 
 188  1
             builder.setId(contract.getId());
 189  1
             if (contract.getKimAttribute() != null) {
 190  1
                 builder.setKimAttribute(KimAttribute.Builder.create(contract.getKimAttribute()));
 191  
             }
 192  1
             if (contract.getKimType() != null) {
 193  1
                 builder.setKimType(KimType.Builder.create(contract.getKimType()));
 194  
             }
 195  1
             builder.setValue(contract.getAttributeValue());
 196  1
             builder.setVersionNumber(contract.getVersionNumber());
 197  1
             builder.setObjectId(contract.getObjectId());
 198  1
             return builder;
 199  
         }
 200  
 
 201  
         @Override
 202  
         public String getId() {
 203  1
             return id;
 204  
         }
 205  
 
 206  
         public void setId(final String id) {
 207  1
             if (StringUtils.isWhitespace(id)) {
 208  0
                 throw new IllegalArgumentException("id is blank");
 209  
             }
 210  1
             this.id = id;
 211  1
         }
 212  
 
 213  
         @Override
 214  
         public String getAssignedToId() {
 215  1
             return assignedToId;
 216  
         }
 217  
 
 218  
         public void setAssignedToId(final String assignedToId) {
 219  1
             this.assignedToId = assignedToId;
 220  1
         }
 221  
 
 222  
         @Override
 223  
         public String getKimTypeId(){
 224  1
             return kimTypeId;
 225  
         }
 226  
 
 227  
         public void setKimTypeId(String kimTypeId) {
 228  1
             this.kimTypeId = kimTypeId;
 229  1
         }
 230  
 
 231  
         @Override
 232  
         public KimType.Builder getKimType() {
 233  2
             return kimType;
 234  
         }
 235  
 
 236  
         public void setKimType(final KimType.Builder kimType) {
 237  1
             this.kimType = kimType;
 238  1
         }
 239  
 
 240  
         @Override
 241  
         public KimAttribute.Builder getKimAttribute() {
 242  2
             return kimAttribute;
 243  
         }
 244  
 
 245  
         public void setKimAttribute(final KimAttribute.Builder kimAttribute) {
 246  1
             this.kimAttribute = kimAttribute;
 247  1
         }
 248  
 
 249  
         @Override
 250  
         public String getAttributeValue() {
 251  1
             return attributeValue;
 252  
         }
 253  
 
 254  
         public void setValue(final String attributeValue) {
 255  1
             this.attributeValue = attributeValue;
 256  1
         }
 257  
 
 258  
         @Override
 259  
         public Long getVersionNumber() {
 260  1
             return versionNumber;
 261  
         }
 262  
 
 263  
         public void setVersionNumber(Long versionNumber) {
 264  1
             this.versionNumber = versionNumber;
 265  1
         }
 266  
 
 267  
         @Override
 268  
         public String getObjectId() {
 269  1
             return objectId;
 270  
         }
 271  
 
 272  
         public void setObjectId(final String objectId) {
 273  1
             this.objectId = objectId;
 274  1
         }
 275  
 
 276  
         @Override
 277  
         public KimAttributeData build() {
 278  1
             return new KimAttributeData(this);
 279  
         }
 280  
     }
 281  
 
 282  
     /**
 283  
      * Defines some internal constants used on this class.
 284  
      */
 285  0
     static class Constants {
 286  
         final static String ROOT_ELEMENT_NAME = "kimAttributeData";
 287  
         final static String TYPE_NAME = "KimAttributeDataType";
 288  1
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 289  
     }
 290  
 
 291  
     /**
 292  
      * A private class which exposes constants which define the XML element names to use
 293  
      * when this object is marshalled to XML.
 294  
      */
 295  0
     static class Elements {
 296  
         final static String ID = "id";
 297  
         final static String ASSIGNED_TO_ID = "assignedToId";
 298  
         final static String KIM_TYPE_ID = "kimTypeId";
 299  
         final static String KIM_TYPE = "kimType";
 300  
         final static String KIM_ATTRIBUTE = "kimAttribute";
 301  
         final static String ATTRIBUTE_VALUE = "attributeValue";
 302  
     }
 303  
 }