Coverage Report - org.kuali.rice.kim.api.common.delegate.Delegate
 
Classes in this File Line Coverage Branch Coverage Complexity
Delegate
95%
40/42
N/A
1.244
Delegate$1
N/A
N/A
1.244
Delegate$Builder
94%
69/73
91%
11/12
1.244
Delegate$Constants
50%
1/2
N/A
1.244
Delegate$Elements
0%
0/1
N/A
1.244
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  * http://www.opensource.org/licenses/ecl2.php
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing, software
 10  
  * distributed under the License is distributed on an "AS IS" BASIS,
 11  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
  * See the License for the specific language governing permissions and
 13  
  * limitations under the License.
 14  
  */
 15  
 package org.kuali.rice.kim.api.common.delegate;
 16  
 
 17  
 import org.apache.commons.lang.StringUtils;
 18  
 import org.apache.commons.lang.builder.EqualsBuilder;
 19  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 20  
 import org.apache.commons.lang.builder.ToStringBuilder;
 21  
 import org.kuali.rice.core.api.CoreConstants;
 22  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 23  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 24  
 import org.kuali.rice.core.api.mo.common.active.InactivatableFromToImpl;
 25  
 import org.kuali.rice.core.util.AttributeSet;
 26  
 import org.w3c.dom.Element;
 27  
 
 28  
 import javax.xml.bind.annotation.XmlAccessType;
 29  
 import javax.xml.bind.annotation.XmlAccessorType;
 30  
 import javax.xml.bind.annotation.XmlAnyElement;
 31  
 import javax.xml.bind.annotation.XmlElement;
 32  
 import javax.xml.bind.annotation.XmlRootElement;
 33  
 import javax.xml.bind.annotation.XmlType;
 34  
 import java.util.Collection;
 35  
 
 36  
 /**
 37  
  * An immutable and JAXB annotated DTO of a DelegateContract
 38  
  */
 39  
 @XmlRootElement(name = Delegate.Constants.ROOT_ELEMENT_NAME)
 40  
 @XmlAccessorType(XmlAccessType.NONE)
 41  
 @XmlType(name = Delegate.Constants.TYPE_NAME, propOrder = {
 42  
         Delegate.Elements.DELEGATION_ID,
 43  
         Delegate.Elements.DELEGATION_TYPE_CODE,
 44  
         Delegate.Elements.MEMBER_ID,
 45  
         Delegate.Elements.MEMBER_TYPE_CODE,
 46  
         Delegate.Elements.QUALIFIER,
 47  
         Delegate.Elements.ROLE_MEMBER_ID,
 48  
         Delegate.Elements.ROLE_ID,
 49  
         Delegate.Elements.DELEGATION_MEMBER_ID,
 50  
         Delegate.Elements.MEMBER_NAME,
 51  
         Delegate.Elements.MEMBER_NAMESPACE_CODE,
 52  
         CoreConstants.CommonElements.VERSION_NUMBER,
 53  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 54  
 })
 55  10
 public final class Delegate extends InactivatableFromToImpl implements DelegateContract, ModelObjectComplete {
 56  
 
 57  
     private static final long serialVersionUID = 1L;
 58  
 
 59  
     @XmlElement(name = Elements.DELEGATION_ID, required = true)
 60  
     private final String delegationId;
 61  
 
 62  
     @XmlElement(name = Elements.DELEGATION_TYPE_CODE, required = true)
 63  
     private final String delegationTypeCode;
 64  
 
 65  
     @XmlElement(name = Elements.MEMBER_ID, required = true)
 66  
     private final String memberId;
 67  
 
 68  
     @XmlElement(name = Elements.MEMBER_TYPE_CODE, required = true)
 69  
     private final String memberTypeCode;
 70  
 
 71  
     @XmlElement(name = Elements.QUALIFIER, required = true)
 72  
     private final AttributeSet qualifier;
 73  
 
 74  
     @XmlElement(name = Elements.ROLE_MEMBER_ID, required = true)
 75  
     private final String roleMemberId;
 76  
 
 77  
     @XmlElement(name = Elements.ROLE_ID)
 78  
     private final String roleId;
 79  
 
 80  
     @XmlElement(name = Elements.DELEGATION_MEMBER_ID)
 81  
     private final String delegationMemberId;
 82  
 
 83  
     @XmlElement(name = Elements.MEMBER_NAME)
 84  
     private final String memberName;
 85  
 
 86  
     @XmlElement(name = Elements.MEMBER_NAMESPACE_CODE)
 87  
     private final String memberNamespaceCode;
 88  
 
 89  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER)
 90  
     private final Long versionNumber;
 91  
 
 92  19
     @SuppressWarnings("unused")
 93  
     @XmlAnyElement
 94  
     private final Collection<Element> _futureElements = null;
 95  
 
 96  
 
 97  
     @SuppressWarnings("unused")
 98  9
     private Delegate() {
 99  9
         delegationId = null;
 100  9
         delegationTypeCode = null;
 101  9
         memberId = null;
 102  9
         memberTypeCode = null;
 103  9
         qualifier = null;
 104  9
         roleMemberId = null;
 105  9
         roleId = null;
 106  9
         delegationMemberId = null;
 107  9
         memberName = null;
 108  9
         memberNamespaceCode = null;
 109  9
         versionNumber = null;
 110  9
     }
 111  
 
 112  10
     private Delegate(Builder b) {
 113  10
         delegationId = b.getDelegationId();
 114  10
         delegationTypeCode = b.getDelegationTypeCode();
 115  10
         memberId = b.getMemberId();
 116  10
         memberTypeCode = b.getMemberTypeCode();
 117  10
         qualifier = b.getQualifier();
 118  10
         roleMemberId = b.getRoleMemberId();
 119  10
         roleId = b.getRoleId();
 120  10
         delegationMemberId = b.getDelegationMemberId();
 121  10
         memberName = b.getMemberName();
 122  10
         memberNamespaceCode = b.getMemberNamespaceCode();
 123  10
         versionNumber = b.getVersionNumber();
 124  10
     }
 125  
 
 126  
     public String getDelegationTypeCode() {
 127  2
         return this.delegationTypeCode;
 128  
     }
 129  
 
 130  
     public String getMemberTypeCode() {
 131  2
         return this.memberTypeCode;
 132  
     }
 133  
 
 134  
     public String getMemberId() {
 135  2
         return this.memberId;
 136  
     }
 137  
 
 138  
     public AttributeSet getQualifier() {
 139  2
         return this.qualifier;
 140  
     }
 141  
 
 142  
     public String getDelegationId() {
 143  2
         return this.delegationId;
 144  
     }
 145  
 
 146  
     public String getRoleMemberId() {
 147  2
         return this.roleMemberId;
 148  
     }
 149  
 
 150  
     public String getMemberName() {
 151  1
         return this.memberName;
 152  
     }
 153  
 
 154  
     public String getMemberNamespaceCode() {
 155  1
         return this.memberNamespaceCode;
 156  
     }
 157  
 
 158  
     public String getDelegationMemberId() {
 159  1
         return this.delegationMemberId;
 160  
     }
 161  
 
 162  
     public String getRoleId() {
 163  1
         return this.roleId;
 164  
     }
 165  
 
 166  
     public Long getVersionNumber() {
 167  1
         return this.versionNumber;
 168  
     }
 169  
 
 170  
     @Override
 171  
     public int hashCode() {
 172  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 173  
     }
 174  
 
 175  
     @Override
 176  
     public boolean equals(Object obj) {
 177  6
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 178  
     }
 179  
 
 180  
     @Override
 181  
     public String toString() {
 182  0
         return ToStringBuilder.reflectionToString(this);
 183  
     }
 184  
 
 185  3
     public static final class Builder implements DelegateContract, ModelBuilder, ModelObjectComplete {
 186  
 
 187  
         private String delegationId;
 188  
         private String delegationTypeCode;
 189  
         private String memberId;
 190  
         private String memberTypeCode;
 191  
         private AttributeSet qualifier;
 192  
         private String roleMemberId;
 193  
         private String roleId;
 194  
         private String delegationMemberId;
 195  
         private String memberName;
 196  
         private String memberNamespaceCode;
 197  
         private Long versionNumber;
 198  
 
 199  16
         private Builder() {
 200  16
         }
 201  
 
 202  
         public static Builder create(DelegateContract delegateContract) {
 203  1
             Builder b = new Builder();
 204  1
             b.setDelegationId(delegateContract.getDelegationId());
 205  1
             b.setDelegationTypeCode(delegateContract.getDelegationTypeCode());
 206  1
             b.setMemberId(delegateContract.getMemberId());
 207  1
             b.setMemberTypeCode(delegateContract.getMemberTypeCode());
 208  1
             b.setQualifier(delegateContract.getQualifier());
 209  1
             b.setRoleMemberId(delegateContract.getRoleMemberId());
 210  1
             b.setRoleId(delegateContract.getRoleId());
 211  1
             b.setDelegationMemberId(delegateContract.getDelegationMemberId());
 212  1
             b.setMemberName(delegateContract.getMemberName());
 213  1
             b.setMemberNamespaceCode(delegateContract.getMemberNamespaceCode());
 214  1
             b.setVersionNumber(delegateContract.getVersionNumber());
 215  
 
 216  1
             return b;
 217  
         }
 218  
 
 219  
         public static Builder create(String delegationId, String delegationTypeCode, String memberId,
 220  
                                      String memberTypeCode, String roleMemberId, AttributeSet qualifier) {
 221  15
             Builder b = new Builder();
 222  
 
 223  15
             b.setDelegationId(delegationId);
 224  15
             b.setDelegationTypeCode(delegationTypeCode);
 225  15
             b.setMemberId(memberId);
 226  15
             b.setMemberTypeCode(memberTypeCode);
 227  15
             b.setRoleMemberId(roleMemberId);
 228  15
             b.setQualifier(qualifier);
 229  
 
 230  15
             return b;
 231  
         }
 232  
 
 233  
         public Delegate build() {
 234  10
             return new Delegate(this);
 235  
         }
 236  
 
 237  
         public String getDelegationId() {
 238  10
             return delegationId;
 239  
         }
 240  
 
 241  
         public String getDelegationTypeCode() {
 242  10
             return delegationTypeCode;
 243  
         }
 244  
 
 245  
         public String getMemberId() {
 246  10
             return memberId;
 247  
         }
 248  
 
 249  
         public String getMemberTypeCode() {
 250  10
             return memberTypeCode;
 251  
         }
 252  
 
 253  
         public AttributeSet getQualifier() {
 254  10
             return qualifier;
 255  
         }
 256  
 
 257  
         public String getRoleMemberId() {
 258  10
             return roleMemberId;
 259  
         }
 260  
 
 261  
         public String getRoleId() {
 262  10
             return roleId;
 263  
         }
 264  
 
 265  
         public String getDelegationMemberId() {
 266  10
             return delegationMemberId;
 267  
         }
 268  
 
 269  
         public String getMemberName() {
 270  10
             return memberName;
 271  
         }
 272  
 
 273  
         public String getMemberNamespaceCode() {
 274  10
             return memberNamespaceCode;
 275  
         }
 276  
 
 277  
         public void setDelegationTypeCode(String delegationTypeCode) {
 278  18
             if (StringUtils.isBlank(delegationTypeCode)) {
 279  2
                 throw new IllegalArgumentException("delegationTypeCode cannot be blank or null");
 280  
             }
 281  16
             this.delegationTypeCode = delegationTypeCode;
 282  16
         }
 283  
 
 284  
         public void setMemberId(String memberId) {
 285  18
             if (StringUtils.isBlank(memberId)) {
 286  2
                 throw new IllegalArgumentException("memberId cannot be blank or null");
 287  
             }
 288  16
             this.memberId = memberId;
 289  16
         }
 290  
 
 291  
         public void setMemberTypeCode(String memberTypeCode) {
 292  18
             if (StringUtils.isBlank(memberTypeCode)) {
 293  2
                 throw new IllegalArgumentException("memberTypeCode cannot be blank or null");
 294  
             }
 295  16
             this.memberTypeCode = memberTypeCode;
 296  16
         }
 297  
 
 298  
         public void setQualifier(AttributeSet qualifier) {
 299  16
             if (qualifier == null) {
 300  0
                 this.qualifier = new AttributeSet();
 301  
             }
 302  16
             this.qualifier = qualifier;
 303  16
         }
 304  
 
 305  
         public void setDelegationId(String delegationId) {
 306  18
             if (StringUtils.isBlank(delegationId)) {
 307  2
                 throw new IllegalArgumentException("delegationId cannot be blank or null");
 308  
             }
 309  16
             this.delegationId = delegationId;
 310  16
         }
 311  
 
 312  
         public void setRoleMemberId(String roleMemberId) {
 313  18
             if (StringUtils.isBlank(roleMemberId)) {
 314  2
                 throw new IllegalArgumentException("roleMemberId cannot be blank or null");
 315  
             }
 316  16
             this.roleMemberId = roleMemberId;
 317  16
         }
 318  
 
 319  
         @SuppressWarnings("unused")
 320  
         public void setMemberName(String memberName) {
 321  1
             this.memberName = memberName;
 322  1
         }
 323  
 
 324  
         @SuppressWarnings("unused")
 325  
         public void setMemberNamespaceCode(String memberNamespaceCode) {
 326  1
             this.memberNamespaceCode = memberNamespaceCode;
 327  1
         }
 328  
 
 329  
         @SuppressWarnings("unused")
 330  
         public void setDelegationMemberId(String delegationMemberId) {
 331  1
             this.delegationMemberId = delegationMemberId;
 332  1
         }
 333  
 
 334  
         public void setRoleId(String roleId) {
 335  1
             this.roleId = roleId;
 336  1
         }
 337  
 
 338  
         public Long getVersionNumber() {
 339  10
             return versionNumber;
 340  
         }
 341  
 
 342  
         public void setVersionNumber(Long versionNumber) {
 343  1
             this.versionNumber = versionNumber;
 344  1
         }
 345  
 
 346  
         @Override
 347  
         public int hashCode() {
 348  0
             return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 349  
         }
 350  
 
 351  
         @Override
 352  
         public boolean equals(Object obj) {
 353  0
             return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 354  
         }
 355  
 
 356  
         @Override
 357  
         public String toString() {
 358  0
             return ToStringBuilder.reflectionToString(this);
 359  
         }
 360  
     }
 361  
 
 362  
     /**
 363  
      * A private class which exposes constants which define the XML element names to use
 364  
      * when this object is marshalled to XML.
 365  
      */
 366  0
     static class Elements {
 367  
         final static String DELEGATION_ID = "delegationId";
 368  
         final static String DELEGATION_TYPE_CODE = "delegationTypeCode";
 369  
         final static String MEMBER_ID = "memberId";
 370  
         final static String MEMBER_TYPE_CODE = "memberTypeCode";
 371  
         final static String QUALIFIER = "qualifier";
 372  
         final static String ROLE_MEMBER_ID = "roleMemberId";
 373  
         final static String ROLE_ID = "roleId";
 374  
         final static String DELEGATION_MEMBER_ID = "delegationMemberId";
 375  
         final static String MEMBER_NAME = "memberName";
 376  
         final static String MEMBER_NAMESPACE_CODE = "memberNamespaceCode";
 377  
     }
 378  
 
 379  
     /**
 380  
      * Defines some internal constants used on this class.
 381  
      */
 382  0
     static class Constants {
 383  
         final static String ROOT_ELEMENT_NAME = "delegate";
 384  
         final static String TYPE_NAME = "DelegateType";
 385  1
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 386  
     }
 387  
 }