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