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