Coverage Report - org.kuali.rice.kim.api.identity.CodedAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
CodedAttribute
0%
0/24
N/A
1.167
CodedAttribute$1
N/A
N/A
1.167
CodedAttribute$Builder
0%
0/35
0%
0/4
1.167
CodedAttribute$Cache
0%
0/1
N/A
1.167
CodedAttribute$Constants
0%
0/1
N/A
1.167
CodedAttribute$Elements
0%
0/1
N/A
1.167
 
 1  
 /**
 2  
  * Copyright 2005-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  
 package org.kuali.rice.kim.api.identity;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 import javax.xml.bind.annotation.XmlAccessType;
 21  
 import javax.xml.bind.annotation.XmlAccessorType;
 22  
 import javax.xml.bind.annotation.XmlAnyElement;
 23  
 import javax.xml.bind.annotation.XmlElement;
 24  
 import javax.xml.bind.annotation.XmlRootElement;
 25  
 import javax.xml.bind.annotation.XmlType;
 26  
 
 27  
 import org.apache.commons.lang.StringUtils;
 28  
 import org.kuali.rice.core.api.CoreConstants;
 29  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 30  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 31  
 import org.kuali.rice.kim.api.KimConstants;
 32  
 import org.w3c.dom.Element;
 33  
 
 34  
 @XmlRootElement(name = CodedAttribute.Constants.ROOT_ELEMENT_NAME)
 35  
 @XmlAccessorType(XmlAccessType.NONE)
 36  
 @XmlType(name = CodedAttribute.Constants.TYPE_NAME, propOrder = {
 37  
     CodedAttribute.Elements.CODE,
 38  
     CodedAttribute.Elements.NAME,
 39  
     CodedAttribute.Elements.SORT_CODE,
 40  
     CodedAttribute.Elements.ACTIVE,
 41  
     CoreConstants.CommonElements.VERSION_NUMBER,
 42  
     CoreConstants.CommonElements.OBJECT_ID,
 43  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 44  
 })
 45  0
 public final class CodedAttribute extends AbstractDataTransferObject
 46  
     implements CodedAttributeContract
 47  
 {
 48  
     @XmlElement(name = Elements.CODE, required = true)
 49  
     private final String code;
 50  
     @XmlElement(name = Elements.NAME, required = false)
 51  
     private final String name;
 52  
     @XmlElement(name = Elements.SORT_CODE, required = false)
 53  
     private final String sortCode;
 54  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 55  
     private final Long versionNumber;
 56  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 57  
     private final String objectId;
 58  
     @XmlElement(name = Elements.ACTIVE, required = false)
 59  
     private final boolean active;
 60  0
     @SuppressWarnings("unused")
 61  
     @XmlAnyElement
 62  
     private final Collection<Element> _futureElements = null;
 63  
 
 64  
     /**
 65  
      * Private constructor used only by JAXB.
 66  
      * 
 67  
      */
 68  0
     private CodedAttribute() {
 69  0
         this.name = null;
 70  0
         this.code = null;
 71  0
         this.sortCode = null;
 72  0
         this.versionNumber = null;
 73  0
         this.objectId = null;
 74  0
         this.active = false;
 75  0
     }
 76  
 
 77  0
     private CodedAttribute(Builder builder) {
 78  0
         this.name = builder.getName();
 79  0
         this.code = builder.getCode();
 80  0
         this.sortCode = builder.getSortCode();
 81  0
         this.versionNumber = builder.getVersionNumber();
 82  0
         this.objectId = builder.getObjectId();
 83  0
         this.active = builder.isActive();
 84  0
     }
 85  
 
 86  
     @Override
 87  
     public String getName() {
 88  0
         return this.name;
 89  
     }
 90  
 
 91  
     @Override
 92  
     public String getCode() {
 93  0
         return this.code;
 94  
     }
 95  
 
 96  
     @Override
 97  
     public String getSortCode() {
 98  0
         return this.sortCode;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public Long getVersionNumber() {
 103  0
         return this.versionNumber;
 104  
     }
 105  
 
 106  
     @Override
 107  
     public String getObjectId() {
 108  0
         return this.objectId;
 109  
     }
 110  
 
 111  
     @Override
 112  
     public boolean isActive() {
 113  0
         return this.active;
 114  
     }
 115  
 
 116  
 
 117  
     /**
 118  
      * A builder which can be used to construct {@link CodedAttribute} instances.  Enforces the constraints of the {@link CodedAttributeContract}.
 119  
      * 
 120  
      */
 121  0
     public final static class Builder
 122  
         implements Serializable, ModelBuilder, CodedAttributeContract
 123  
     {
 124  
 
 125  
         private String name;
 126  
         private String code;
 127  
         private String sortCode;
 128  
         private Long versionNumber;
 129  
         private String objectId;
 130  
         private boolean active;
 131  
 
 132  0
         private Builder(String code) {
 133  0
             setCode(code);
 134  0
         }
 135  
 
 136  
         public static Builder create(String code) {
 137  0
             return new Builder(code);
 138  
         }
 139  
 
 140  
         public static Builder create(CodedAttributeContract contract) {
 141  0
             if (contract == null) {
 142  0
                 throw new IllegalArgumentException("contract was null");
 143  
             }
 144  
             // TODO if create() is modified to accept required parameters, this will need to be modified
 145  0
             Builder builder = create(contract.getCode());
 146  0
             builder.setName(contract.getName());
 147  0
             builder.setSortCode(contract.getSortCode());
 148  0
             builder.setVersionNumber(contract.getVersionNumber());
 149  0
             builder.setObjectId(contract.getObjectId());
 150  0
             builder.setActive(contract.isActive());
 151  0
             return builder;
 152  
         }
 153  
 
 154  
         public CodedAttribute build() {
 155  0
             return new CodedAttribute(this);
 156  
         }
 157  
 
 158  
         @Override
 159  
         public String getName() {
 160  0
             return this.name;
 161  
         }
 162  
 
 163  
         @Override
 164  
         public String getCode() {
 165  0
             return this.code;
 166  
         }
 167  
 
 168  
         @Override
 169  
         public String getSortCode() {
 170  0
             return this.sortCode;
 171  
         }
 172  
 
 173  
         @Override
 174  
         public Long getVersionNumber() {
 175  0
             return this.versionNumber;
 176  
         }
 177  
 
 178  
         @Override
 179  
         public String getObjectId() {
 180  0
             return this.objectId;
 181  
         }
 182  
 
 183  
         @Override
 184  
         public boolean isActive() {
 185  0
             return this.active;
 186  
         }
 187  
 
 188  
         public void setName(String name) {
 189  0
             this.name = name;
 190  0
         }
 191  
 
 192  
         public void setCode(String code) {
 193  0
             if (StringUtils.isWhitespace(code)) {
 194  0
                 throw new IllegalArgumentException("code is empty");
 195  
             }
 196  0
             this.code = code;
 197  0
         }
 198  
 
 199  
         public void setSortCode(String sortCode) {
 200  0
             this.sortCode = sortCode;
 201  0
         }
 202  
 
 203  
         public void setVersionNumber(Long versionNumber) {
 204  0
             this.versionNumber = versionNumber;
 205  0
         }
 206  
 
 207  
         public void setObjectId(String objectId) {
 208  0
             this.objectId = objectId;
 209  0
         }
 210  
 
 211  
         public void setActive(boolean active) {
 212  0
             this.active = active;
 213  0
         }
 214  
 
 215  
     }
 216  
 
 217  
 
 218  
     /**
 219  
      * Defines some internal constants used on this class.
 220  
      * 
 221  
      */
 222  0
     static class Constants {
 223  
 
 224  
         final static String ROOT_ELEMENT_NAME = "codedAttribute";
 225  
         final static String TYPE_NAME = "CodedAttributeType";
 226  
 
 227  
     }
 228  
 
 229  
 
 230  
     /**
 231  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 232  
      * 
 233  
      */
 234  0
     static class Elements {
 235  
 
 236  
         final static String NAME = "name";
 237  
         final static String CODE = "code";
 238  
         final static String SORT_CODE = "sortCode";
 239  
         final static String ACTIVE = "active";
 240  
 
 241  
     }
 242  
 
 243  0
     public static class Cache {
 244  
         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + CodedAttribute.Constants.TYPE_NAME;
 245  
     }
 246  
 
 247  
 }