Coverage Report - org.kuali.rice.kim.api.identity.address.EntityAddress
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityAddress
100%
76/76
100%
2/2
1.294
EntityAddress$1
N/A
N/A
1.294
EntityAddress$Builder
91%
88/96
60%
12/20
1.294
EntityAddress$Constants
0%
0/1
N/A
1.294
EntityAddress$Elements
0%
0/1
N/A
1.294
 
 1  
 package org.kuali.rice.kim.api.identity.address;
 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.kuali.rice.kim.api.identity.Type;
 18  
 import org.w3c.dom.Element;
 19  
 
 20  21
 @XmlRootElement(name = EntityAddress.Constants.ROOT_ELEMENT_NAME)
 21  
 @XmlAccessorType(XmlAccessType.NONE)
 22  
 @XmlType(name = EntityAddress.Constants.TYPE_NAME, propOrder = {
 23  
     EntityAddress.Elements.ID,
 24  
     EntityAddress.Elements.ENTITY_TYPE_CODE,
 25  
     EntityAddress.Elements.ENTITY_ID,
 26  
     EntityAddress.Elements.ADDRESS_TYPE,
 27  
     EntityAddress.Elements.LINE1,
 28  
     EntityAddress.Elements.LINE2,
 29  
     EntityAddress.Elements.LINE3,
 30  
     EntityAddress.Elements.CITY_NAME,
 31  
     EntityAddress.Elements.STATE_CODE,
 32  
     EntityAddress.Elements.POSTAL_CODE,
 33  
     EntityAddress.Elements.COUNTRY_CODE,
 34  
 
 35  
     EntityAddress.Elements.LINE1_UNMASKED,
 36  
     EntityAddress.Elements.LINE2_UNMASKED,
 37  
     EntityAddress.Elements.LINE3_UNMASKED,
 38  
     EntityAddress.Elements.CITY_NAME_UNMASKED,
 39  
     EntityAddress.Elements.STATE_CODE_UNMASKED,
 40  
     EntityAddress.Elements.POSTAL_CODE_UNMASKED,
 41  
     EntityAddress.Elements.COUNTRY_CODE_UNMASKED,
 42  
     EntityAddress.Elements.SUPPRESS_ADDRESS,
 43  
     EntityAddress.Elements.DEFAULT_VALUE,
 44  
     EntityAddress.Elements.ACTIVE,
 45  
     CoreConstants.CommonElements.VERSION_NUMBER,
 46  
     CoreConstants.CommonElements.OBJECT_ID,
 47  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 48  
 })
 49  13
 public final class EntityAddress extends AbstractDataTransferObject
 50  
     implements EntityAddressContract
 51  
 {
 52  
     @XmlElement(name = Elements.ID, required = false)
 53  
     private final String id;
 54  
     @XmlElement(name = Elements.ENTITY_TYPE_CODE, required = false)
 55  
     private final String entityTypeCode;
 56  
     @XmlElement(name = Elements.ENTITY_ID, required = false)
 57  
     private final String entityId;
 58  
     @XmlElement(name = Elements.ADDRESS_TYPE, required = false)
 59  
     private final Type addressType;
 60  
     @XmlElement(name = Elements.LINE1, required = false)
 61  
     private final String line1;
 62  
     @XmlElement(name = Elements.LINE2, required = false)
 63  
     private final String line2;
 64  
     @XmlElement(name = Elements.LINE3, required = false)
 65  
     private final String line3;
 66  
     @XmlElement(name = Elements.CITY_NAME, required = false)
 67  
     private final String cityName;
 68  
     @XmlElement(name = Elements.STATE_CODE, required = false)
 69  
     private final String stateCode;
 70  
     @XmlElement(name = Elements.POSTAL_CODE, required = false)
 71  
     private final String postalCode;
 72  
     @XmlElement(name = Elements.COUNTRY_CODE, required = false)
 73  
     private final String countryCode;
 74  
     @XmlElement(name = Elements.LINE1_UNMASKED, required = false)
 75  
     private final String line1Unmasked;
 76  
     @XmlElement(name = Elements.LINE2_UNMASKED, required = false)
 77  
     private final String line2Unmasked;
 78  
     @XmlElement(name = Elements.LINE3_UNMASKED, required = false)
 79  
     private final String line3Unmasked;
 80  
     @XmlElement(name = Elements.CITY_NAME_UNMASKED, required = false)
 81  
     private final String cityNameUnmasked;
 82  
     @XmlElement(name = Elements.STATE_CODE_UNMASKED, required = false)
 83  
     private final String stateCodeUnmasked;
 84  
     @XmlElement(name = Elements.POSTAL_CODE_UNMASKED, required = false)
 85  
     private final String postalCodeUnmasked;
 86  
     @XmlElement(name = Elements.COUNTRY_CODE_UNMASKED, required = false)
 87  
     private final String countryCodeUnmasked;
 88  
     @XmlElement(name = Elements.SUPPRESS_ADDRESS, required = false)
 89  
     private final boolean suppressAddress;
 90  
     @XmlElement(name = Elements.DEFAULT_VALUE, required = false)
 91  
     private final boolean defaultValue;
 92  
     @XmlElement(name = Elements.ACTIVE, required = false)
 93  
     private final boolean active;
 94  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 95  
     private final Long versionNumber;
 96  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 97  
     private final String objectId;
 98  23
     @SuppressWarnings("unused")
 99  
     @XmlAnyElement
 100  
     private final Collection<Element> _futureElements = null;
 101  
 
 102  
     /**
 103  
      * Private constructor used only by JAXB.
 104  
      * 
 105  
      */
 106  10
     private EntityAddress() {
 107  10
         this.entityId = null;
 108  10
         this.entityTypeCode = null;
 109  10
         this.addressType = null;
 110  10
         this.line1 = null;
 111  10
         this.line2 = null;
 112  10
         this.line3 = null;
 113  10
         this.cityName = null;
 114  10
         this.stateCode = null;
 115  10
         this.postalCode = null;
 116  10
         this.countryCode = null;
 117  10
         this.line1Unmasked = null;
 118  10
         this.line2Unmasked = null;
 119  10
         this.line3Unmasked = null;
 120  10
         this.cityNameUnmasked = null;
 121  10
         this.stateCodeUnmasked = null;
 122  10
         this.postalCodeUnmasked = null;
 123  10
         this.countryCodeUnmasked = null;
 124  10
         this.suppressAddress = false;
 125  10
         this.defaultValue = false;
 126  10
         this.versionNumber = null;
 127  10
         this.objectId = null;
 128  10
         this.active = false;
 129  10
         this.id = null;
 130  10
     }
 131  
 
 132  13
     private EntityAddress(Builder builder) {
 133  13
         this.entityId = builder.getEntityId();
 134  13
         this.entityTypeCode = builder.getEntityTypeCode();
 135  
 
 136  13
         this.addressType = (builder.getAddressType() != null) ? builder.getAddressType().build() : null;
 137  13
         this.line1 = builder.getLine1();
 138  13
         this.line2 = builder.getLine2();
 139  13
         this.line3 = builder.getLine3();
 140  13
         this.cityName = builder.getCityName();
 141  13
         this.stateCode = builder.getStateCode();
 142  13
         this.postalCode = builder.getPostalCode();
 143  13
         this.countryCode = builder.getCountryCode();
 144  13
         this.line1Unmasked = builder.getLine1Unmasked();
 145  13
         this.line2Unmasked = builder.getLine2Unmasked();
 146  13
         this.line3Unmasked = builder.getLine3Unmasked();
 147  13
         this.cityNameUnmasked = builder.getCityNameUnmasked();
 148  13
         this.stateCodeUnmasked = builder.getStateCodeUnmasked();
 149  13
         this.postalCodeUnmasked = builder.getPostalCodeUnmasked();
 150  13
         this.countryCodeUnmasked = builder.getCountryCodeUnmasked();
 151  13
         this.suppressAddress = builder.isSuppressAddress();
 152  13
         this.defaultValue = builder.isDefaultValue();
 153  13
         this.versionNumber = builder.getVersionNumber();
 154  13
         this.objectId = builder.getObjectId();
 155  13
         this.active = builder.isActive();
 156  13
         this.id = builder.getId();
 157  13
     }
 158  
 
 159  
     @Override
 160  
     public String getEntityId() {
 161  7
         return this.entityId;
 162  
     }
 163  
 
 164  
     @Override
 165  
     public String getEntityTypeCode() {
 166  7
         return this.entityTypeCode;
 167  
     }
 168  
 
 169  
     @Override
 170  
     public Type getAddressType() {
 171  21
         return this.addressType;
 172  
     }
 173  
 
 174  
     @Override
 175  
     public String getLine1() {
 176  2
         return this.line1;
 177  
     }
 178  
 
 179  
     @Override
 180  
     public String getLine2() {
 181  2
         return this.line2;
 182  
     }
 183  
 
 184  
     @Override
 185  
     public String getLine3() {
 186  2
         return this.line3;
 187  
     }
 188  
 
 189  
     @Override
 190  
     public String getCityName() {
 191  2
         return this.cityName;
 192  
     }
 193  
 
 194  
     @Override
 195  
     public String getStateCode() {
 196  2
         return this.stateCode;
 197  
     }
 198  
 
 199  
     @Override
 200  
     public String getPostalCode() {
 201  2
         return this.postalCode;
 202  
     }
 203  
 
 204  
     @Override
 205  
     public String getCountryCode() {
 206  2
         return this.countryCode;
 207  
     }
 208  
 
 209  
     @Override
 210  
     public String getLine1Unmasked() {
 211  7
         return this.line1Unmasked;
 212  
     }
 213  
 
 214  
     @Override
 215  
     public String getLine2Unmasked() {
 216  7
         return this.line2Unmasked;
 217  
     }
 218  
 
 219  
     @Override
 220  
     public String getLine3Unmasked() {
 221  7
         return this.line3Unmasked;
 222  
     }
 223  
 
 224  
     @Override
 225  
     public String getCityNameUnmasked() {
 226  7
         return this.cityNameUnmasked;
 227  
     }
 228  
 
 229  
     @Override
 230  
     public String getStateCodeUnmasked() {
 231  7
         return this.stateCodeUnmasked;
 232  
     }
 233  
 
 234  
     @Override
 235  
     public String getPostalCodeUnmasked() {
 236  7
         return this.postalCodeUnmasked;
 237  
     }
 238  
 
 239  
     @Override
 240  
     public String getCountryCodeUnmasked() {
 241  7
         return this.countryCodeUnmasked;
 242  
     }
 243  
 
 244  
     @Override
 245  
     public boolean isSuppressAddress() {
 246  7
         return this.suppressAddress;
 247  
     }
 248  
 
 249  
     @Override
 250  
     public boolean isDefaultValue() {
 251  7
         return this.defaultValue;
 252  
     }
 253  
 
 254  
     @Override
 255  
     public Long getVersionNumber() {
 256  7
         return this.versionNumber;
 257  
     }
 258  
 
 259  
     @Override
 260  
     public String getObjectId() {
 261  7
         return this.objectId;
 262  
     }
 263  
 
 264  
     @Override
 265  
     public boolean isActive() {
 266  7
         return this.active;
 267  
     }
 268  
 
 269  
     @Override
 270  
     public String getId() {
 271  7
         return this.id;
 272  
     }
 273  
 
 274  
     /**
 275  
      * A builder which can be used to construct {@link EntityAddress} instances.  Enforces the constraints of the {@link EntityAddressContract}.
 276  
      * 
 277  
      */
 278  5
     public final static class Builder
 279  
         implements Serializable, ModelBuilder, EntityAddressContract
 280  
     {
 281  
 
 282  
         private String entityId;
 283  
         private String entityTypeCode;
 284  
         private Type.Builder addressType;
 285  
         private String line1Unmasked;
 286  
         private String line2Unmasked;
 287  
         private String line3Unmasked;
 288  
         private String cityNameUnmasked;
 289  
         private String stateCodeUnmasked;
 290  
         private String postalCodeUnmasked;
 291  
         private String countryCodeUnmasked;
 292  
         private boolean suppressAddress;
 293  
         private boolean defaultValue;
 294  
         private Long versionNumber;
 295  
         private String objectId;
 296  
         private boolean active;
 297  
         private String id;
 298  
 
 299  11
         private Builder() {}
 300  
 
 301  
         public static Builder create() {
 302  11
             return new Builder();
 303  
         }
 304  
 
 305  
         public static Builder create(EntityAddressContract contract) {
 306  8
             if (contract == null) {
 307  0
                 throw new IllegalArgumentException("contract was null");
 308  
             }
 309  8
             Builder builder = create();
 310  8
             builder.setEntityId(contract.getEntityId());
 311  8
             builder.setSuppressAddress(contract.isSuppressAddress());
 312  8
             builder.setEntityTypeCode(contract.getEntityTypeCode());
 313  8
             if (contract.getAddressType() != null) {
 314  7
                 builder.setAddressType(Type.Builder.create(contract.getAddressType()));
 315  
             }
 316  8
             builder.setLine1(contract.getLine1Unmasked());
 317  8
             builder.setLine2(contract.getLine2Unmasked());
 318  8
             builder.setLine3(contract.getLine3Unmasked());
 319  8
             builder.setCityName(contract.getCityNameUnmasked());
 320  8
             builder.setStateCode(contract.getStateCodeUnmasked());
 321  8
             builder.setPostalCode(contract.getPostalCodeUnmasked());
 322  8
             builder.setCountryCode(contract.getCountryCodeUnmasked());
 323  8
             builder.setDefaultValue(contract.isDefaultValue());
 324  8
             builder.setVersionNumber(contract.getVersionNumber());
 325  8
             builder.setObjectId(contract.getObjectId());
 326  8
             builder.setActive(contract.isActive());
 327  8
             builder.setId(contract.getId());
 328  8
             return builder;
 329  
         }
 330  
 
 331  
         public EntityAddress build() {
 332  13
             return new EntityAddress(this);
 333  
         }
 334  
 
 335  
         @Override
 336  
         public String getEntityId() {
 337  13
             return this.entityId;
 338  
         }
 339  
 
 340  
         @Override
 341  
         public String getEntityTypeCode() {
 342  13
             return this.entityTypeCode;
 343  
         }
 344  
 
 345  
         @Override
 346  
         public Type.Builder getAddressType() {
 347  24
             return this.addressType;
 348  
         }
 349  
 
 350  
         @Override
 351  
         public String getLine1() {
 352  13
             if (isSuppressAddress()) {
 353  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
 354  
             }
 355  13
             return this.line1Unmasked;
 356  
 
 357  
         }
 358  
 
 359  
         @Override
 360  
         public String getLine2() {
 361  13
             if (isSuppressAddress()) {
 362  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
 363  
             }
 364  13
             return this.line2Unmasked;
 365  
         }
 366  
 
 367  
         @Override
 368  
         public String getLine3() {
 369  13
             if (isSuppressAddress()) {
 370  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
 371  
             }
 372  13
             return this.line3Unmasked;
 373  
         }
 374  
 
 375  
         @Override
 376  
         public String getCityName() {
 377  13
             if (isSuppressAddress()) {
 378  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
 379  
             }
 380  13
             return this.cityNameUnmasked;
 381  
         }
 382  
 
 383  
         @Override
 384  
         public String getStateCode() {
 385  13
             if (isSuppressAddress()) {
 386  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE;
 387  
             }
 388  13
             return this.stateCodeUnmasked;
 389  
         }
 390  
 
 391  
         @Override
 392  
         public String getPostalCode() {
 393  13
             if (isSuppressAddress()) {
 394  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_ZIP;
 395  
             }
 396  13
             return this.postalCodeUnmasked;
 397  
         }
 398  
 
 399  
         @Override
 400  
         public String getCountryCode() {
 401  13
             if (isSuppressAddress()) {
 402  0
                 return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE;
 403  
             }
 404  13
             return this.countryCodeUnmasked;
 405  
         }
 406  
 
 407  
         @Override
 408  
         public String getLine1Unmasked() {
 409  13
             return this.line1Unmasked;
 410  
         }
 411  
 
 412  
         @Override
 413  
         public String getLine2Unmasked() {
 414  13
             return this.line2Unmasked;
 415  
         }
 416  
 
 417  
         @Override
 418  
         public String getLine3Unmasked() {
 419  13
             return this.line3Unmasked;
 420  
         }
 421  
 
 422  
         @Override
 423  
         public String getCityNameUnmasked() {
 424  13
             return this.cityNameUnmasked;
 425  
         }
 426  
 
 427  
         @Override
 428  
         public String getStateCodeUnmasked() {
 429  13
             return this.stateCodeUnmasked;
 430  
         }
 431  
 
 432  
         @Override
 433  
         public String getPostalCodeUnmasked() {
 434  13
             return this.postalCodeUnmasked;
 435  
         }
 436  
 
 437  
         @Override
 438  
         public String getCountryCodeUnmasked() {
 439  13
             return this.countryCodeUnmasked;
 440  
         }
 441  
 
 442  
         @Override
 443  
         public boolean isSuppressAddress() {
 444  104
             return this.suppressAddress;
 445  
         }
 446  
 
 447  
         @Override
 448  
         public boolean isDefaultValue() {
 449  21
             return this.defaultValue;
 450  
         }
 451  
 
 452  
         @Override
 453  
         public Long getVersionNumber() {
 454  13
             return this.versionNumber;
 455  
         }
 456  
 
 457  
         @Override
 458  
         public String getObjectId() {
 459  13
             return this.objectId;
 460  
         }
 461  
 
 462  
         @Override
 463  
         public boolean isActive() {
 464  21
             return this.active;
 465  
         }
 466  
 
 467  
         @Override
 468  
         public String getId() {
 469  13
             return this.id;
 470  
         }
 471  
 
 472  
         public void setEntityId(String entityId) {
 473  8
             this.entityId = entityId;
 474  8
         }
 475  
 
 476  
         public void setEntityTypeCode(String entityTypeCode) {
 477  8
             this.entityTypeCode = entityTypeCode;
 478  8
         }
 479  
 
 480  
         public void setAddressType(Type.Builder addressType) {
 481  7
             this.addressType = addressType;
 482  7
         }
 483  
 
 484  
         public void setLine1(String line1) {
 485  8
             this.line1Unmasked = line1;
 486  8
         }
 487  
 
 488  
         public void setLine2(String line2) {
 489  8
             this.line2Unmasked = line2;
 490  8
         }
 491  
 
 492  
         public void setLine3(String line3) {
 493  8
             this.line3Unmasked = line3;
 494  8
         }
 495  
 
 496  
         public void setCityName(String cityName) {
 497  8
             this.cityNameUnmasked = cityName;
 498  8
         }
 499  
 
 500  
         public void setStateCode(String stateCode) {
 501  8
             this.stateCodeUnmasked = stateCode;
 502  8
         }
 503  
 
 504  
         public void setPostalCode(String postalCode) {
 505  8
             this.postalCodeUnmasked = postalCode;
 506  8
         }
 507  
 
 508  
         public void setCountryCode(String countryCode) {
 509  8
             this.countryCodeUnmasked = countryCode;
 510  8
         }
 511  
 
 512  
         private void setSuppressAddress(boolean suppressAddress) {
 513  8
             this.suppressAddress = suppressAddress;
 514  8
         }
 515  
 
 516  
         public void setDefaultValue(boolean defaultValue) {
 517  8
             this.defaultValue = defaultValue;
 518  8
         }
 519  
 
 520  
         public void setVersionNumber(Long versionNumber) {
 521  8
             this.versionNumber = versionNumber;
 522  8
         }
 523  
 
 524  
         public void setObjectId(String objectId) {
 525  8
             this.objectId = objectId;
 526  8
         }
 527  
 
 528  
         public void setActive(boolean active) {
 529  8
             this.active = active;
 530  8
         }
 531  
 
 532  
         public void setId(String id) {
 533  9
             if (StringUtils.isWhitespace(id)) {
 534  1
                 throw new IllegalArgumentException("id is blank");
 535  
             }
 536  8
             this.id = id;
 537  8
         }
 538  
 
 539  
     }
 540  
 
 541  
 
 542  
     /**
 543  
      * Defines some internal constants used on this class.
 544  
      * 
 545  
      */
 546  0
     static class Constants {
 547  
 
 548  
         final static String ROOT_ELEMENT_NAME = "entityAddress";
 549  
         final static String TYPE_NAME = "EntityAddressType";
 550  
     }
 551  
 
 552  
 
 553  
     /**
 554  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 555  
      * 
 556  
      */
 557  0
     static class Elements {
 558  
 
 559  
         final static String ENTITY_ID = "entityId";
 560  
         final static String ENTITY_TYPE_CODE = "entityTypeCode";
 561  
         final static String ADDRESS_TYPE = "addressType";
 562  
         final static String LINE1 = "line1";
 563  
         final static String LINE2 = "line2";
 564  
         final static String LINE3 = "line3";
 565  
         final static String CITY_NAME = "cityName";
 566  
         final static String STATE_CODE = "stateCode";
 567  
         final static String POSTAL_CODE = "postalCode";
 568  
         final static String COUNTRY_CODE = "countryCode";
 569  
         final static String LINE1_UNMASKED = "line1Unmasked";
 570  
         final static String LINE2_UNMASKED = "line2Unmasked";
 571  
         final static String LINE3_UNMASKED = "line3Unmasked";
 572  
         final static String CITY_NAME_UNMASKED = "cityNameUnmasked";
 573  
         final static String STATE_CODE_UNMASKED = "stateCodeUnmasked";
 574  
         final static String POSTAL_CODE_UNMASKED = "postalCodeUnmasked";
 575  
         final static String COUNTRY_CODE_UNMASKED = "countryCodeUnmasked";
 576  
         final static String SUPPRESS_ADDRESS = "suppressAddress";
 577  
         final static String DEFAULT_VALUE = "defaultValue";
 578  
         final static String ACTIVE = "active";
 579  
         final static String ID = "id";
 580  
 
 581  
     }
 582  
 
 583  
 }