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