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