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