Coverage Report - org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityNamePrincipalName
0%
0/15
0%
0/2
1.267
EntityNamePrincipalName$1
N/A
N/A
1.267
EntityNamePrincipalName$Builder
57%
11/19
25%
1/4
1.267
EntityNamePrincipalName$Constants
0%
0/2
N/A
1.267
EntityNamePrincipalName$Elements
0%
0/1
N/A
1.267
 
 1  
 package org.kuali.rice.kim.api.identity.principal;
 2  
 
 3  
 import org.apache.commons.lang.builder.EqualsBuilder;
 4  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 5  
 import org.apache.commons.lang.builder.ToStringBuilder;
 6  
 import org.kuali.rice.core.api.CoreConstants;
 7  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 8  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 9  
 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
 10  
 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationContract;
 11  
 import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
 12  
 import org.kuali.rice.kim.api.identity.entity.EntityContract;
 13  
 import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier;
 14  
 import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierContract;
 15  
 import org.kuali.rice.kim.api.identity.name.EntityName;
 16  
 import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences;
 17  
 import org.kuali.rice.kim.api.identity.type.EntityTypeDataContract;
 18  
 import org.kuali.rice.kim.api.identity.type.EntityTypeDataDefault;
 19  
 import org.w3c.dom.Element;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 import java.io.Serializable;
 28  
 import java.util.ArrayList;
 29  
 import java.util.Collection;
 30  
 import java.util.List;
 31  
 
 32  
 @XmlRootElement(name = EntityNamePrincipalName.Constants.ROOT_ELEMENT_NAME)
 33  
 @XmlAccessorType(XmlAccessType.NONE)
 34  
 @XmlType(name = EntityNamePrincipalName.Constants.TYPE_NAME, propOrder = {
 35  
     EntityNamePrincipalName.Elements.DEFAULT_NAME,
 36  
     EntityNamePrincipalName.Elements.PRINCIPAL_NAME,
 37  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 38  
 })
 39  0
 public class EntityNamePrincipalName implements ModelObjectComplete {
 40  
     @XmlElement(name = Elements.PRINCIPAL_NAME, required = false)
 41  
     private final String principalName;
 42  
     @XmlElement(name = Elements.DEFAULT_NAME, required = false)
 43  
     private final EntityName defaultName;
 44  0
     @SuppressWarnings("unused")
 45  
     @XmlAnyElement
 46  
     private final Collection<Element> _futureElements = null;
 47  
 
 48  
 
 49  0
     private EntityNamePrincipalName() {
 50  0
         this.principalName = null;
 51  0
         this.defaultName = null;
 52  0
     }
 53  
 
 54  0
     private EntityNamePrincipalName(Builder builder) {
 55  0
         this.principalName = builder.getPrincipalName();
 56  0
         this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build();
 57  0
     }
 58  
 
 59  
     public String getPrincipalName() {
 60  0
         return principalName;
 61  
     }
 62  
 
 63  
     public EntityName getDefaultName() {
 64  0
         return defaultName;
 65  
     }
 66  
     /**
 67  
      * A builder which can be used to construct {@link EntityDefault} instances.
 68  
      *
 69  
      */
 70  1
     public final static class Builder
 71  
         implements Serializable, ModelBuilder
 72  
     {
 73  
         private String principalName;
 74  
         private EntityName.Builder defaultName;
 75  
 
 76  
         public static Builder create() {
 77  0
             return new Builder();
 78  
         }
 79  
 
 80  
         public static Builder create(String principalName, EntityName.Builder defaultName) {
 81  1
             Builder builder = new Builder();
 82  1
             builder.setPrincipalName(principalName);
 83  1
             builder.setDefaultName(defaultName);
 84  1
             return builder;
 85  
         }
 86  
 
 87  
         public static Builder create(EntityNamePrincipalName immutable) {
 88  1
             if (immutable == null) {
 89  1
                 throw new IllegalArgumentException("contract was null");
 90  
             }
 91  0
             Builder builder = new Builder();
 92  0
             if (immutable.getDefaultName() != null) {
 93  0
                 builder.setDefaultName(EntityName.Builder.create(immutable.getDefaultName()));
 94  
             }
 95  0
             return builder;
 96  
         }
 97  
 
 98  
         public String getPrincipalName() {
 99  0
             return principalName;
 100  
         }
 101  
 
 102  
         public void setPrincipalName(String principalName) {
 103  1
             this.principalName = principalName;
 104  1
         }
 105  
 
 106  
         public EntityName.Builder getDefaultName() {
 107  0
             return defaultName;
 108  
         }
 109  
 
 110  
         public void setDefaultName(EntityName.Builder defaultName) {
 111  1
             this.defaultName = defaultName;
 112  1
         }
 113  
 
 114  
         public EntityNamePrincipalName build() {
 115  0
             return new EntityNamePrincipalName(this);
 116  
         }
 117  
 
 118  
     }
 119  
 
 120  
     @Override
 121  
     public int hashCode() {
 122  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 123  
     }
 124  
 
 125  
     @Override
 126  
     public boolean equals(Object object) {
 127  0
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 128  
     }
 129  
 
 130  
     @Override
 131  
     public String toString() {
 132  0
         return ToStringBuilder.reflectionToString(this);
 133  
     }
 134  
 
 135  
     /**
 136  
      * Defines some internal constants used on this class.
 137  
      *
 138  
      */
 139  0
     static class Constants {
 140  
 
 141  
         final static String ROOT_ELEMENT_NAME = "entityNamePrincipalName";
 142  
         final static String TYPE_NAME = "EntityNamePrincipalNameType";
 143  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
 144  
 
 145  
     }
 146  
 
 147  
 
 148  
     /**
 149  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 150  
      *
 151  
      */
 152  0
     static class Elements {
 153  
         final static String DEFAULT_NAME = "defaultName";
 154  
         final static String PRINCIPAL_NAME = "principalName";
 155  
     }
 156  
 
 157  
 }