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