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