Coverage Report - org.kuali.rice.kim.api.identity.email.EntityEmail
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityEmail
0%
0/40
0%
0/2
1.211
EntityEmail$1
N/A
N/A
1.211
EntityEmail$Builder
0%
0/55
0%
0/8
1.211
EntityEmail$Constants
0%
0/1
N/A
1.211
EntityEmail$Elements
0%
0/1
N/A
1.211
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kim.api.identity.email;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 21  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 22  
 import org.kuali.rice.kim.api.KimApiConstants;
 23  
 import org.kuali.rice.kim.api.identity.CodedAttribute;
 24  
 
 25  
 import javax.xml.bind.Element;
 26  
 import javax.xml.bind.annotation.XmlAccessType;
 27  
 import javax.xml.bind.annotation.XmlAccessorType;
 28  
 import javax.xml.bind.annotation.XmlAnyElement;
 29  
 import javax.xml.bind.annotation.XmlElement;
 30  
 import javax.xml.bind.annotation.XmlRootElement;
 31  
 import javax.xml.bind.annotation.XmlType;
 32  
 import java.io.Serializable;
 33  
 import java.util.Collection;
 34  
 
 35  0
 @XmlRootElement(name = EntityEmail.Constants.ROOT_ELEMENT_NAME)
 36  
 @XmlAccessorType(XmlAccessType.NONE)
 37  
 @XmlType(name = EntityEmail.Constants.TYPE_NAME, propOrder = {
 38  
     EntityEmail.Elements.ID,
 39  
     EntityEmail.Elements.ENTITY_TYPE_CODE,
 40  
     EntityEmail.Elements.ENTITY_ID,
 41  
     EntityEmail.Elements.EMAIL_TYPE,
 42  
     EntityEmail.Elements.EMAIL_ADDRESS,
 43  
     EntityEmail.Elements.EMAIL_ADDRESS_UNMASKED,
 44  
     EntityEmail.Elements.SUPPRESS_EMAIL,
 45  
     EntityEmail.Elements.DEFAULT_VALUE,
 46  
     EntityEmail.Elements.ACTIVE,
 47  
     CoreConstants.CommonElements.VERSION_NUMBER,
 48  
     CoreConstants.CommonElements.OBJECT_ID,
 49  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 50  
 })
 51  0
 public class EntityEmail extends AbstractDataTransferObject implements EntityEmailContract{
 52  
     
 53  
     @XmlElement(name = Elements.ID, required = false)
 54  
     private final String id;
 55  
     @XmlElement(name = Elements.ENTITY_TYPE_CODE, required = false)
 56  
     private final String entityTypeCode;
 57  
     @XmlElement(name = Elements.ENTITY_ID, required = false)
 58  
     private final String entityId;
 59  
     @XmlElement(name = Elements.EMAIL_TYPE, required = false)
 60  
     private final CodedAttribute emailType;
 61  
     @XmlElement(name = Elements.EMAIL_ADDRESS, required = false)
 62  
     private final String emailAddress;
 63  
     @XmlElement(name = Elements.EMAIL_ADDRESS_UNMASKED, required = false)
 64  
     private final String emailAddressUnmasked;
 65  
     @XmlElement(name = Elements.SUPPRESS_EMAIL, required = false)
 66  
     private final boolean suppressEmail;
 67  
     @XmlElement(name = Elements.DEFAULT_VALUE, required = false)
 68  
     private final boolean defaultValue;
 69  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 70  
     private final Long versionNumber;
 71  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 72  
     private final String objectId;
 73  
     @XmlElement(name = Elements.ACTIVE, required = false)
 74  
     private final boolean active;
 75  0
     @SuppressWarnings("unused")
 76  
     @XmlAnyElement
 77  
     private final Collection<Element> _futureElements = null;
 78  
 
 79  
     /**
 80  
      * Private constructor used only by JAXB.
 81  
      * 
 82  
      */
 83  0
     private EntityEmail() {
 84  0
         this.id = null;
 85  0
         this.entityId = null;
 86  0
         this.entityTypeCode = null;
 87  0
         this.emailType = null;
 88  0
         this.emailAddress = null;
 89  0
         this.emailAddressUnmasked = null;
 90  0
         this.suppressEmail = false;
 91  0
         this.defaultValue = false;
 92  0
         this.versionNumber = null;
 93  0
         this.objectId = null;
 94  0
         this.active = false;
 95  0
     }
 96  
 
 97  0
     private EntityEmail(Builder builder) {
 98  0
         this.id = builder.getId();
 99  0
         this.entityId = builder.getEntityId();
 100  0
         this.entityTypeCode = builder.getEntityTypeCode();
 101  0
         this.emailType = (builder.getEmailType() != null) ? builder.getEmailType().build() : null;
 102  0
         this.emailAddress = builder.getEmailAddress();
 103  0
         this.emailAddressUnmasked = builder.getEmailAddressUnmasked();
 104  0
         this.suppressEmail = builder.isSuppressEmail();
 105  0
         this.defaultValue = builder.isDefaultValue();
 106  0
         this.versionNumber = builder.getVersionNumber();
 107  0
         this.objectId = builder.getObjectId();
 108  0
         this.active = builder.isActive();
 109  0
     }
 110  
 
 111  
     @Override
 112  
     public String getId() {
 113  0
         return this.id;
 114  
     }
 115  
 
 116  
     @Override
 117  
     public String getEntityId() {
 118  0
         return this.entityId;
 119  
     }
 120  
 
 121  
     @Override
 122  
     public String getEntityTypeCode() {
 123  0
         return this.entityTypeCode;
 124  
     }
 125  
 
 126  
     @Override
 127  
     public CodedAttribute getEmailType() {
 128  0
         return this.emailType;
 129  
     }
 130  
 
 131  
     @Override
 132  
     public String getEmailAddress() {
 133  0
         return this.emailAddress;
 134  
     }
 135  
 
 136  
     @Override
 137  
     public String getEmailAddressUnmasked() {
 138  0
         return this.emailAddressUnmasked;
 139  
     }
 140  
 
 141  
     @Override
 142  
     public boolean isSuppressEmail() {
 143  0
         return this.suppressEmail;
 144  
     }
 145  
 
 146  
     @Override
 147  
     public boolean isDefaultValue() {
 148  0
         return this.defaultValue;
 149  
     }
 150  
 
 151  
     @Override
 152  
     public Long getVersionNumber() {
 153  0
         return this.versionNumber;
 154  
     }
 155  
 
 156  
     @Override
 157  
     public String getObjectId() {
 158  0
         return this.objectId;
 159  
     }
 160  
 
 161  
     @Override
 162  
     public boolean isActive() {
 163  0
         return this.active;
 164  
     }
 165  
 
 166  
     /**
 167  
      * A builder which can be used to construct {@link EntityEmail} instances.  Enforces the constraints of the {@link org.kuali.rice.kim.api.identity.email.EntityEmailContract}.
 168  
      * 
 169  
      */
 170  0
     public final static class Builder
 171  
         implements Serializable, ModelBuilder, EntityEmailContract
 172  
     {
 173  
 
 174  
         private String id;
 175  
         private String entityId;
 176  
         private String entityTypeCode;
 177  
         private CodedAttribute.Builder emailType;
 178  
         private String emailAddressUnmasked;
 179  
         private boolean suppressEmail;
 180  
         private boolean defaultValue;
 181  
         private Long versionNumber;
 182  
         private String objectId;
 183  
         private boolean active;
 184  
 
 185  0
         private Builder() {
 186  
 
 187  0
         }
 188  
 
 189  
         public static Builder create() {
 190  0
             return new Builder();
 191  
         }
 192  
 
 193  
         public static Builder create(EntityEmailContract contract) {
 194  0
             if (contract == null) {
 195  0
                 throw new IllegalArgumentException("contract was null");
 196  
             }
 197  0
             Builder builder = create();
 198  0
             builder.setId(contract.getId());
 199  0
             builder.setEntityId(contract.getEntityId());
 200  0
             builder.setEntityTypeCode(contract.getEntityTypeCode());
 201  0
             builder.setSuppressEmail(contract.isSuppressEmail());
 202  0
             if (contract.getEmailType() != null) {
 203  0
                 builder.setEmailType(CodedAttribute.Builder.create(contract.getEmailType()));
 204  
             }
 205  0
             builder.setEmailAddress(contract.getEmailAddressUnmasked());
 206  0
             builder.setDefaultValue(contract.isDefaultValue());
 207  0
             builder.setVersionNumber(contract.getVersionNumber());
 208  0
             builder.setObjectId(contract.getObjectId());
 209  0
             builder.setActive(contract.isActive());
 210  0
             return builder;
 211  
         }
 212  
 
 213  
         public EntityEmail build() {
 214  0
             return new EntityEmail(this);
 215  
         }
 216  
 
 217  
         @Override
 218  
         public String getId() {
 219  0
             return this.id;
 220  
         }
 221  
 
 222  
         @Override
 223  
         public String getEntityTypeCode() {
 224  0
             return this.entityTypeCode;
 225  
         }
 226  
 
 227  
         @Override
 228  
         public String getEntityId() {
 229  0
             return this.entityId;
 230  
         }
 231  
 
 232  
         @Override
 233  
         public CodedAttribute.Builder getEmailType() {
 234  0
             return this.emailType;
 235  
         }
 236  
 
 237  
         @Override
 238  
         public String getEmailAddress() {
 239  0
             if (isSuppressEmail()) {
 240  0
                 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
 241  
             }
 242  0
             return this.emailAddressUnmasked;
 243  
         }
 244  
 
 245  
         @Override
 246  
         public String getEmailAddressUnmasked() {
 247  0
             return this.emailAddressUnmasked;
 248  
         }
 249  
 
 250  
         @Override
 251  
         public boolean isSuppressEmail() {
 252  0
             return this.suppressEmail;
 253  
         }
 254  
 
 255  
         @Override
 256  
         public boolean isDefaultValue() {
 257  0
             return this.defaultValue;
 258  
         }
 259  
 
 260  
         @Override
 261  
         public Long getVersionNumber() {
 262  0
             return this.versionNumber;
 263  
         }
 264  
 
 265  
         @Override
 266  
         public String getObjectId() {
 267  0
             return this.objectId;
 268  
         }
 269  
 
 270  
         @Override
 271  
         public boolean isActive() {
 272  0
             return this.active;
 273  
         }
 274  
 
 275  
         public void setId(String id) {
 276  0
             if (StringUtils.isWhitespace(id)) {
 277  0
                 throw new IllegalArgumentException("id is blank");
 278  
             }
 279  0
             this.id = id;
 280  0
         }
 281  
 
 282  
         public void setEntityTypeCode(String entityTypeCode) {
 283  0
             this.entityTypeCode = entityTypeCode;
 284  0
         }
 285  
 
 286  
         public void setEntityId(String entityId) {
 287  0
             this.entityId = entityId;
 288  0
         }
 289  
 
 290  
         public void setEmailType(CodedAttribute.Builder emailType) {
 291  0
             this.emailType = emailType;
 292  0
         }
 293  
 
 294  
         public void setEmailAddress(String emailAddress) {
 295  0
             this.emailAddressUnmasked = emailAddress;
 296  0
         }
 297  
 
 298  
         private void setSuppressEmail(boolean suppressEmail) {
 299  0
             this.suppressEmail = suppressEmail;
 300  0
         }
 301  
 
 302  
         public void setDefaultValue(boolean defaultValue) {
 303  0
             this.defaultValue = defaultValue;
 304  0
         }
 305  
 
 306  
         public void setVersionNumber(Long versionNumber) {
 307  0
             this.versionNumber = versionNumber;
 308  0
         }
 309  
 
 310  
         public void setObjectId(String objectId) {
 311  0
             this.objectId = objectId;
 312  0
         }
 313  
 
 314  
         public void setActive(boolean active) {
 315  0
             this.active = active;
 316  0
         }
 317  
 
 318  
     }
 319  
 
 320  
 
 321  
     /**
 322  
      * Defines some internal constants used on this class.
 323  
      * 
 324  
      */
 325  0
     static class Constants {
 326  
 
 327  
         final static String ROOT_ELEMENT_NAME = "entityEmail";
 328  
         final static String TYPE_NAME = "EntityEmailType";
 329  
     }
 330  
 
 331  
 
 332  
     /**
 333  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 334  
      * 
 335  
      */
 336  0
     static class Elements {
 337  
 
 338  
         final static String ID = "id";
 339  
         final static String ENTITY_TYPE_CODE = "entityTypeCode";
 340  
         final static String ENTITY_ID = "entityId";
 341  
         final static String EMAIL_TYPE = "emailType";
 342  
         final static String EMAIL_ADDRESS = "emailAddress";
 343  
         final static String EMAIL_ADDRESS_UNMASKED = "emailAddressUnmasked";
 344  
         final static String SUPPRESS_EMAIL = "suppressEmail";
 345  
         final static String DEFAULT_VALUE = "defaultValue";
 346  
         final static String ACTIVE = "active";
 347  
 
 348  
     }
 349  
 
 350  
 }