Coverage Report - org.kuali.rice.krms.api.repository.type.KrmsTypeAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
KrmsTypeAttribute
0%
0/21
N/A
1.429
KrmsTypeAttribute$1
N/A
N/A
1.429
KrmsTypeAttribute$Builder
0%
0/35
0%
0/10
1.429
KrmsTypeAttribute$Constants
0%
0/1
N/A
1.429
KrmsTypeAttribute$Elements
0%
0/1
N/A
1.429
 
 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.krms.api.repository.type;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.apache.commons.lang.StringUtils;
 29  
 import org.kuali.rice.core.api.CoreConstants;
 30  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 31  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 32  
 
 33  
 /**
 34  
  * Concrete model object implementation of KRMS KrmsTypeAttribute. 
 35  
  * immutable. 
 36  
  * Instances of KrmsTypeAttribute can be (un)marshalled to and from XML.
 37  
  *
 38  
  */
 39  
 @XmlRootElement(name = KrmsTypeAttribute.Constants.ROOT_ELEMENT_NAME)
 40  
 @XmlAccessorType(XmlAccessType.NONE)
 41  
 @XmlType(name = KrmsTypeAttribute.Constants.TYPE_NAME, propOrder = {
 42  
                 KrmsTypeAttribute.Elements.ID,
 43  
                 KrmsTypeAttribute.Elements.TYPE_ID,
 44  
                 KrmsTypeAttribute.Elements.ATTR_DEFN_ID,
 45  
                 KrmsTypeAttribute.Elements.SEQ_NO,
 46  
                 KrmsTypeAttribute.Elements.ACTIVE,
 47  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 48  
 })
 49  0
 public final class KrmsTypeAttribute extends AbstractDataTransferObject implements KrmsTypeAttributeContract {
 50  
         private static final long serialVersionUID = -304265575559412478L;
 51  
         
 52  
         @XmlElement(name = Elements.ID, required = false)
 53  
         private String id;
 54  
         @XmlElement(name = Elements.TYPE_ID, required = true)
 55  
         private String typeId;
 56  
         @XmlElement(name = Elements.ATTR_DEFN_ID, required = true)
 57  
         private String attributeDefinitionId;
 58  
         @XmlElement(name = Elements.SEQ_NO, required = true)
 59  
         private Integer sequenceNumber;
 60  
         @XmlElement(name = Elements.ACTIVE, required = false)
 61  
         private boolean active;
 62  
 
 63  0
         @SuppressWarnings("unused")
 64  
     @XmlAnyElement
 65  
     private final Collection<org.w3c.dom.Element> _futureElements = null;
 66  
         
 67  
          /** 
 68  
      * This constructor should never be called.  It is only present for use during JAXB unmarshalling. 
 69  
      */
 70  0
     private KrmsTypeAttribute() {
 71  0
             this.id = null;
 72  0
             this.typeId = null;
 73  0
             this.attributeDefinitionId = null;
 74  0
             this.sequenceNumber = null;
 75  0
             this.active = false;
 76  0
     }
 77  
     
 78  
     /**
 79  
          * Constructs a KRMS KrmsTypeAttribute from the given builder.  
 80  
          * This constructor is private and should only ever be invoked from the builder.
 81  
          * 
 82  
          * @param builder the Builder from which to construct the KrmsTypeAttribute
 83  
          */
 84  0
     private KrmsTypeAttribute(Builder builder) {
 85  0
         this.id = builder.getId();
 86  0
         this.typeId = builder.getTypeId();
 87  0
         this.attributeDefinitionId = builder.getAttributeDefinitionId();
 88  0
         this.sequenceNumber = builder.getSequenceNumber();
 89  0
         this.active = builder.isActive();
 90  0
     }
 91  
     
 92  
         public String getId() {
 93  0
                 return this.id;
 94  
         }
 95  
         
 96  
         public String getTypeId() {
 97  0
                 return this.typeId;
 98  
         }
 99  
 
 100  
         public String getAttributeDefinitionId() {
 101  0
                 return this.attributeDefinitionId;
 102  
         }
 103  
 
 104  
         public Integer getSequenceNumber() {
 105  0
                 return this.sequenceNumber;
 106  
         }
 107  
         
 108  
         public boolean isActive() {
 109  0
                 return this.active; 
 110  
         }
 111  
 
 112  
         /**
 113  
      * This builder is used to construct instances of KrmsTypeAttribute.  
 114  
      */
 115  0
     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  
 
 124  
                 /**
 125  
                  * Private constructor for creating a builder with all of it's required attributes.
 126  
                  */
 127  0
         private Builder(String typeId, String attributeDefinitionId, Integer sequenceNumber) {
 128  0
             setTypeId(typeId);
 129  0
             setAttributeDefinitionId(attributeDefinitionId);
 130  0
             setSequenceNumber(sequenceNumber);
 131  0
                         setActive(true);
 132  0
         }
 133  
 
 134  
         /**
 135  
          * Creates a builder from the given parameters.
 136  
          * 
 137  
          * @param typeId the KrmsType Id
 138  
          * @param attributeDefinitionId The attributeDefinitionId
 139  
          * @param sequenceNumber 
 140  
          * @return an instance of the builder with the fields already populated
 141  
          * @throws IllegalArgumentException if the either the id, name or namespace is null or blank
 142  
          */
 143  
         public static Builder create(String typeId, String attributeDefinitionId, Integer sequenceNumber) {
 144  0
             return new Builder(typeId, attributeDefinitionId, sequenceNumber);
 145  
         }
 146  
         
 147  
         public static Builder create(KrmsTypeAttributeContract contract){
 148  0
                 if (contract == null) {
 149  0
                 throw new IllegalArgumentException("contract is null");
 150  
             }
 151  0
                 Builder builder = new Builder(contract.getTypeId(),
 152  
                                 contract.getAttributeDefinitionId(),
 153  
                                 contract.getSequenceNumber());
 154  0
             builder.setId(contract.getId());
 155  0
                 return builder;
 156  
         }
 157  
 
 158  
                 /**
 159  
                  * Sets the value of the id on this builder to the given value.
 160  
                  * 
 161  
                  * @param id the id value to set
 162  
                  */
 163  
         public void setId(String id) {
 164  0
             this.id = id;
 165  0
         }
 166  
 
 167  
                 public void setTypeId(String typeId) {
 168  0
             if (null != typeId && StringUtils.isBlank(typeId)) {
 169  0
                 throw new IllegalArgumentException("typeId must be null or non-blank");
 170  
             }
 171  0
                         this.typeId = typeId;
 172  0
                 }
 173  
 
 174  
                 public void setAttributeDefinitionId(String attributeDefinitionId) {
 175  0
             if (StringUtils.isBlank(attributeDefinitionId)) {
 176  0
                 throw new IllegalArgumentException("the attribute definition id is blank");
 177  
             }
 178  0
                         this.attributeDefinitionId = attributeDefinitionId;
 179  0
                 }
 180  
                 
 181  
                 public void setSequenceNumber(Integer sequenceNumber) {
 182  0
                         if (sequenceNumber == null){
 183  0
                                  throw new IllegalArgumentException("the sequence number is null");
 184  
                         }
 185  0
                         this.sequenceNumber = sequenceNumber;
 186  0
                 }
 187  
 
 188  
                 public void setActive(boolean active) {
 189  0
                         this.active = active;
 190  0
                 }
 191  
 
 192  
                 public String getId() {
 193  0
                         return id;
 194  
                 }
 195  
 
 196  
                 public String getTypeId() {
 197  0
                         return typeId;
 198  
                 }
 199  
 
 200  
                 public String getAttributeDefinitionId() {
 201  0
                         return attributeDefinitionId;
 202  
                 }
 203  
                 
 204  
                 public Integer getSequenceNumber() {
 205  0
                         return sequenceNumber;
 206  
                 }
 207  
 
 208  
                 public boolean isActive() {
 209  0
                         return active;
 210  
                 }
 211  
 
 212  
                 /**
 213  
                  * Builds an instance of a KrmsTypeAttribute based on the current state of the builder.
 214  
                  * 
 215  
                  * @return the fully-constructed KrmsTypeAttribute
 216  
                  */
 217  
         @Override
 218  
         public KrmsTypeAttribute build() {
 219  0
             return new KrmsTypeAttribute(this);
 220  
         }
 221  
                 
 222  
     }
 223  
 
 224  
         /**
 225  
          * Defines some internal constants used on this class.
 226  
          */
 227  0
         static class Constants {
 228  
                 final static String ROOT_ELEMENT_NAME = "krmsTypeAttribute";
 229  
                 final static String TYPE_NAME = "KrmsTypeAttributeType";
 230  
         }
 231  
         
 232  
         /**
 233  
          * A private class which exposes constants which define the XML element names to use
 234  
          * when this object is marshalled to XML.
 235  
          */
 236  0
         public static class Elements {
 237  
                 final static String ID = "id";
 238  
                 final static String TYPE_ID = "typeId";
 239  
                 final static String ATTR_DEFN_ID = "attributeDefinitionId";
 240  
                 public final static String SEQ_NO = "sequenceNumber";
 241  
                 final static String ACTIVE = "active";
 242  
         }
 243  
 }