Coverage Report - org.kuali.rice.kim.api.type.KimTypeAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
KimTypeAttribute
0%
0/28
0%
0/2
1.185
KimTypeAttribute$1
N/A
N/A
1.185
KimTypeAttribute$Builder
0%
0/39
0%
0/6
1.185
KimTypeAttribute$Constants
0%
0/1
N/A
1.185
KimTypeAttribute$Elements
0%
0/1
N/A
1.185
 
 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.type;
 17  
 
 18  
 import org.kuali.rice.core.api.CoreConstants;
 19  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 20  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 21  
 import org.kuali.rice.kim.api.common.attribute.KimAttribute;
 22  
 import org.w3c.dom.Element;
 23  
 
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlAnyElement;
 27  
 import javax.xml.bind.annotation.XmlElement;
 28  
 import javax.xml.bind.annotation.XmlRootElement;
 29  
 import javax.xml.bind.annotation.XmlType;
 30  
 import java.io.Serializable;
 31  
 import java.util.Collection;
 32  
 
 33  
 /**
 34  
  * An immutable representation of a {@link KimTypeAttributeContract}.
 35  
  *
 36  
  * <p>To construct an instance of a KimTypeAttribute, use the {@link KimTypeAttribute.Builder} class.<p/>
 37  
  *
 38  
  * @see KimTypeAttributeContract
 39  
  */
 40  0
 @XmlRootElement(name = KimTypeAttribute.Constants.ROOT_ELEMENT_NAME)
 41  
 @XmlAccessorType(XmlAccessType.NONE)
 42  
 @XmlType(name = KimTypeAttribute.Constants.TYPE_NAME, propOrder = {
 43  
         KimTypeAttribute.Elements.ID,
 44  
         KimTypeAttribute.Elements.SORT_CODE,
 45  
         KimTypeAttribute.Elements.KIM_ATTRIBUTE,
 46  
         KimTypeAttribute.Elements.KIM_TYPE_ID,
 47  
         KimTypeAttribute.Elements.ACTIVE,
 48  
         CoreConstants.CommonElements.VERSION_NUMBER,
 49  
         CoreConstants.CommonElements.OBJECT_ID,
 50  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 51  
 })
 52  0
 public final class KimTypeAttribute extends AbstractDataTransferObject implements KimTypeAttributeContract {
 53  
     private static final long serialVersionUID = 1L;
 54  
 
 55  
     @XmlElement(name = KimTypeAttribute.Elements.ID, required = false)
 56  
     private final String id;
 57  
 
 58  
     @XmlElement(name = KimTypeAttribute.Elements.SORT_CODE, required = false)
 59  
     private final String sortCode;
 60  
 
 61  
     @XmlElement(name = KimTypeAttribute.Elements.KIM_ATTRIBUTE, required = false)
 62  
     private final KimAttribute kimAttribute;
 63  
 
 64  
     @XmlElement(name = KimTypeAttribute.Elements.KIM_TYPE_ID, required = false)
 65  
     private final String kimTypeId;
 66  
 
 67  
     @XmlElement(name = KimTypeAttribute.Elements.ACTIVE, required = false)
 68  
     private final boolean active;
 69  
 
 70  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 71  
     private final Long versionNumber;
 72  
 
 73  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 74  
     private final String objectId;
 75  
 
 76  0
     @SuppressWarnings("unused")
 77  
     @XmlAnyElement
 78  
     private final Collection<Element> _futureElements = null;
 79  
 
 80  
     /**
 81  
      * This constructor should never be called except during JAXB unmarshalling.
 82  
      */
 83  0
     private KimTypeAttribute() {
 84  0
         this.id = null;
 85  0
         this.sortCode = null;
 86  0
         this.kimAttribute = null;
 87  0
         this.kimTypeId = null;
 88  0
         this.active = false;
 89  0
         this.versionNumber = Long.valueOf(1L);
 90  0
         this.objectId = null;
 91  0
     }
 92  
 
 93  0
     private KimTypeAttribute(Builder builder) {
 94  0
         this.id = builder.getId();
 95  0
         this.sortCode = builder.getSortCode();
 96  
 
 97  0
         this.kimAttribute = builder.getKimAttribute() != null ? builder.getKimAttribute().build() : null;
 98  0
         this.kimTypeId = builder.getKimTypeId();
 99  0
         this.active = builder.isActive();
 100  0
         this.versionNumber = builder.getVersionNumber();
 101  0
         this.objectId = builder.getObjectId();
 102  0
     }
 103  
 
 104  
     @Override
 105  
     public String getId() {
 106  0
         return id;
 107  
     }
 108  
 
 109  
     @Override
 110  
     public String getSortCode() {
 111  0
         return sortCode;
 112  
     }
 113  
 
 114  
     @Override
 115  
     public KimAttribute getKimAttribute() {
 116  0
         return kimAttribute;
 117  
     }
 118  
 
 119  
     @Override
 120  
     public String getKimTypeId() {
 121  0
         return kimTypeId;
 122  
     }
 123  
 
 124  
     @Override
 125  
     public boolean isActive() {
 126  0
         return active;
 127  
     }
 128  
 
 129  
     @Override
 130  
     public Long getVersionNumber() {
 131  0
         return versionNumber;
 132  
     }
 133  
 
 134  
     @Override
 135  
     public String getObjectId() {
 136  0
         return objectId;
 137  
     }
 138  
 
 139  
     /**
 140  
      * This builder constructs an KimTypeAttribute enforcing the constraints of the {@link KimTypeAttributeContract}.
 141  
      */
 142  0
     public static final class Builder implements KimTypeAttributeContract, ModelBuilder, Serializable {
 143  
         private String id;
 144  
         private String sortCode;
 145  
         private KimAttribute.Builder kimAttribute;
 146  
         private String kimTypeId;
 147  
         private boolean active;
 148  0
         private Long versionNumber = 1L;
 149  
         private String objectId;
 150  
 
 151  0
         private Builder() {
 152  0
         }
 153  
 
 154  
         /**
 155  
          * creates a KimTypeAttribute with the required fields.
 156  
          */
 157  
         public static Builder create() {
 158  0
             return new Builder();
 159  
         }
 160  
 
 161  
         /**
 162  
          * creates a KimTypeAttribute from an existing {@link KimTypeAttributeContract}.
 163  
          */
 164  
         public static Builder create(KimTypeAttributeContract contract) {
 165  0
             Builder builder = new Builder();
 166  0
             builder.setId(contract.getId());
 167  0
             builder.setSortCode(contract.getSortCode());
 168  0
             if (contract.getKimAttribute() != null) {
 169  0
                 builder.setKimAttribute(KimAttribute.Builder.create(contract.getKimAttribute()));
 170  
             }
 171  0
             builder.setKimTypeId(contract.getKimTypeId());
 172  0
             builder.setActive(contract.isActive());
 173  0
             builder.setVersionNumber(contract.getVersionNumber());
 174  0
             builder.setObjectId(contract.getObjectId());
 175  0
             return builder;
 176  
         }
 177  
 
 178  
         @Override
 179  
         public String getId() {
 180  0
             return id;
 181  
         }
 182  
 
 183  
         public void setId(final String id) {
 184  0
             this.id = id;
 185  0
         }
 186  
 
 187  
         @Override
 188  
         public String getSortCode() {
 189  0
             return sortCode;
 190  
         }
 191  
 
 192  
         public void setSortCode(final String sortCode) {
 193  0
             this.sortCode = sortCode;
 194  0
         }
 195  
 
 196  
         @Override
 197  
         public KimAttribute.Builder getKimAttribute() {
 198  0
             return kimAttribute;
 199  
         }
 200  
 
 201  
         public void setKimAttribute(final KimAttribute.Builder kimAttribute) {
 202  0
             this.kimAttribute = kimAttribute;
 203  0
         }
 204  
 
 205  
         @Override
 206  
         public String getKimTypeId() {
 207  0
             return kimTypeId;
 208  
         }
 209  
 
 210  
         public void setKimTypeId(final String kimTypeId) {
 211  0
             this.kimTypeId = kimTypeId;
 212  0
         }
 213  
 
 214  
         @Override
 215  
         public boolean isActive() {
 216  0
             return active;
 217  
         }
 218  
 
 219  
         public void setActive(final boolean active) {
 220  0
             this.active = active;
 221  0
         }
 222  
 
 223  
         @Override
 224  
         public Long getVersionNumber() {
 225  0
             return versionNumber;
 226  
         }
 227  
 
 228  
         public void setVersionNumber(final Long versionNumber) {
 229  0
             if (versionNumber == null || versionNumber <= 0) {
 230  0
                 throw new IllegalArgumentException("versionNumber is invalid");
 231  
             }
 232  
 
 233  0
             this.versionNumber = versionNumber;
 234  0
         }
 235  
 
 236  
         @Override
 237  
         public String getObjectId() {
 238  0
             return objectId;
 239  
         }
 240  
 
 241  
         public void setObjectId(final String objectId) {
 242  0
             this.objectId = objectId;
 243  0
         }
 244  
 
 245  
         @Override
 246  
         public KimTypeAttribute build() {
 247  0
             return new KimTypeAttribute(this);
 248  
         }
 249  
     }
 250  
 
 251  
     /**
 252  
      * Defines some internal constants used on this class.
 253  
      */
 254  0
     static class Constants {
 255  
         static final String ROOT_ELEMENT_NAME = "kimTypeAttribute";
 256  
         static final String TYPE_NAME = "KimTypeAttributeType";
 257  
     }
 258  
 
 259  
     /**
 260  
      * A private class which exposes constants which define the XML element names to use
 261  
      * when this object is marshalled to XML.
 262  
      */
 263  0
     static class Elements {
 264  
         static final String ID = "id";
 265  
         static final String SORT_CODE = "sortCode";
 266  
         static final String KIM_ATTRIBUTE = "kimAttribute";
 267  
         static final String KIM_TYPE_ID = "kimTypeId";
 268  
         static final String ACTIVE = "active";
 269  
     }
 270  
 }