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