Coverage Report - org.kuali.rice.kim.api.common.delegate.DelegateMember
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegateMember
91%
31/34
0%
0/4
1.314
DelegateMember$1
N/A
N/A
1.314
DelegateMember$Builder
89%
43/48
35%
5/14
1.314
DelegateMember$Constants
50%
1/2
N/A
1.314
DelegateMember$Elements
0%
0/1
N/A
1.314
 
 1  
 package org.kuali.rice.kim.api.common.delegate;
 2  
 
 3  
 import org.apache.commons.lang.StringUtils;
 4  
 import org.apache.commons.lang.builder.EqualsBuilder;
 5  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 6  
 import org.apache.commons.lang.builder.ToStringBuilder;
 7  
 import org.kuali.rice.core.api.CoreConstants;
 8  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 9  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 10  
 import org.kuali.rice.core.util.jaxb.SqlTimestampAdapter;
 11  
 import org.w3c.dom.Element;
 12  
 
 13  
 import javax.xml.bind.annotation.XmlAccessType;
 14  
 import javax.xml.bind.annotation.XmlAccessorType;
 15  
 import javax.xml.bind.annotation.XmlAnyElement;
 16  
 import javax.xml.bind.annotation.XmlElement;
 17  
 import javax.xml.bind.annotation.XmlRootElement;
 18  
 import javax.xml.bind.annotation.XmlType;
 19  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 20  
 import java.io.Serializable;
 21  
 import java.sql.Timestamp;
 22  
 import java.util.Collection;
 23  
 
 24  
 @XmlRootElement(name = DelegateMember.Constants.ROOT_ELEMENT_NAME)
 25  
 @XmlAccessorType(XmlAccessType.NONE)
 26  
 @XmlType(name = DelegateMember.Constants.TYPE_NAME, propOrder = {
 27  
         DelegateMember.Elements.DELEGATION_MEMBER_ID,
 28  
         DelegateMember.Elements.DELEGATION_ID,
 29  
         DelegateMember.Elements.MEMBER_ID,
 30  
         DelegateMember.Elements.ROLE_MEMBER_ID,
 31  
         DelegateMember.Elements.TYPE_CODE,
 32  
         CoreConstants.CommonElements.ACTIVE_FROM_DATE,
 33  
         CoreConstants.CommonElements.ACTIVE_TO_DATE,
 34  
         CoreConstants.CommonElements.VERSION_NUMBER,
 35  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 36  
 })
 37  9
 public final class DelegateMember
 38  
         implements ModelObjectComplete, DelegateMemberContract {
 39  
 
 40  
     @XmlElement(name = Elements.DELEGATION_MEMBER_ID, required = true)
 41  
     private final String delegationMemberId;
 42  
 
 43  
     @XmlElement(name = Elements.DELEGATION_ID, required = false)
 44  
     private final String delegationId;
 45  
 
 46  
     @XmlElement(name = Elements.MEMBER_ID, required = false)
 47  
     private final String memberId;
 48  
 
 49  
     @XmlElement(name = Elements.ROLE_MEMBER_ID, required = false)
 50  
     private final String roleMemberId;
 51  
 
 52  
     @XmlElement(name = Elements.TYPE_CODE, required = false)
 53  
     private final String typeCode;
 54  
 
 55  
     @XmlJavaTypeAdapter(SqlTimestampAdapter.class)
 56  
     @XmlElement(name = CoreConstants.CommonElements.ACTIVE_FROM_DATE)
 57  
     private final Timestamp activeFromDate;
 58  
 
 59  
     @XmlJavaTypeAdapter(SqlTimestampAdapter.class)
 60  
     @XmlElement(name = CoreConstants.CommonElements.ACTIVE_TO_DATE)
 61  
     private final Timestamp activeToDate;
 62  
 
 63  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER)
 64  
     private final Long versionNumber;
 65  
 
 66  15
     @SuppressWarnings("unused")
 67  
     @XmlAnyElement
 68  
     private final Collection<Element> _futureElements = null;
 69  
 
 70  
     /**
 71  
      * Private constructor used only by JAXB.
 72  
      */
 73  
     @SuppressWarnings("unused")
 74  6
     private DelegateMember() {
 75  6
         this.delegationMemberId = null;
 76  6
         this.delegationId = null;
 77  6
         this.memberId = null;
 78  6
         this.roleMemberId = null;
 79  6
         this.typeCode = null;
 80  6
         this.versionNumber = null;
 81  6
         this.activeFromDate = null;
 82  6
         this.activeToDate = null;
 83  6
     }
 84  
 
 85  9
     private DelegateMember(Builder builder) {
 86  9
         this.delegationMemberId = builder.getDelegationMemberId();
 87  9
         this.delegationId = builder.getDelegationId();
 88  9
         this.memberId = builder.getMemberId();
 89  9
         this.roleMemberId = builder.getRoleMemberId();
 90  9
         this.typeCode = builder.getTypeCode();
 91  9
         this.versionNumber = builder.getVersionNumber();
 92  9
         this.activeFromDate = builder.getActiveFromDate();
 93  9
         this.activeToDate = builder.getActiveToDate();
 94  9
     }
 95  
 
 96  
 
 97  
     @Override
 98  
     public String getDelegationMemberId() {
 99  1
         return this.delegationMemberId;
 100  
     }
 101  
 
 102  
     @Override
 103  
     public String getDelegationId() {
 104  1
         return this.delegationId;
 105  
     }
 106  
 
 107  
     @Override
 108  
     public String getTypeCode() {
 109  1
         return this.typeCode;
 110  
     }
 111  
 
 112  
     @Override
 113  
     public String getRoleMemberId() {
 114  1
         return this.roleMemberId;
 115  
     }
 116  
 
 117  
     @Override
 118  
     public String getMemberId() {
 119  1
         return this.memberId;
 120  
     }
 121  
 
 122  
     @Override
 123  
     public Long getVersionNumber() {
 124  1
         return this.versionNumber;
 125  
     }
 126  
 
 127  
     @Override
 128  
     public Timestamp getActiveFromDate() {
 129  1
         return activeFromDate;
 130  
     }
 131  
 
 132  
     @Override
 133  
     public Timestamp getActiveToDate() {
 134  1
         return activeToDate;
 135  
     }
 136  
 
 137  
     @Override
 138  
     public boolean isActive(Timestamp activeAsOfDate) {
 139  0
         return (activeFromDate.before(activeAsOfDate) && activeToDate.after(activeAsOfDate));
 140  
     }
 141  
 
 142  
     @Override
 143  
     public int hashCode() {
 144  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 145  
     }
 146  
 
 147  
     @Override
 148  
     public boolean equals(Object object) {
 149  5
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 150  
     }
 151  
 
 152  
     @Override
 153  
     public String toString() {
 154  0
         return ToStringBuilder.reflectionToString(this);
 155  
     }
 156  
 
 157  
 
 158  
     /**
 159  
      * A builder which can be used to construct {@link DelegateMember} instances.  Enforces the constraints of the {@link DelegateMemberContract}.
 160  
      */
 161  1
     public static final class Builder implements Serializable, ModelBuilder, DelegateMemberContract {
 162  
 
 163  
         private String delegationMemberId;
 164  
         private String delegationId;
 165  
         private String memberId;
 166  
         private String roleMemberId;
 167  
         private String typeCode;
 168  
         private Timestamp activeFromDate;
 169  
         private Timestamp activeToDate;
 170  
         private Long versionNumber;
 171  
 
 172  2
         private Builder() {
 173  
 
 174  2
         }
 175  
 
 176  
         public static Builder create() {
 177  2
             return new Builder();
 178  
         }
 179  
 
 180  
         public static Builder create(DelegateMemberContract contract) {
 181  1
             if (contract == null) {
 182  0
                 throw new IllegalArgumentException("contract was null");
 183  
             }
 184  1
             Builder builder = create();
 185  1
             builder.setDelegationMemberId(contract.getDelegationMemberId());
 186  1
             builder.setDelegationId(contract.getDelegationId());
 187  1
             builder.setMemberId(contract.getMemberId());
 188  1
             builder.setRoleMemberId(contract.getRoleMemberId());
 189  1
             builder.setTypeCode(contract.getTypeCode());
 190  1
             builder.setActiveFromDate(contract.getActiveFromDate());
 191  1
             builder.setActiveToDate(contract.getActiveToDate());
 192  1
             builder.setVersionNumber(contract.getVersionNumber());
 193  1
             return builder;
 194  
         }
 195  
 
 196  
         public DelegateMember build() {
 197  9
             if (StringUtils.isEmpty(this.delegationMemberId) || this.versionNumber == null) {
 198  0
                 throw new IllegalStateException("Required fields of delegationMemberId and versionNumber set to valid non-null" +
 199  
                         " values before calling build()");
 200  
             }
 201  9
             return new DelegateMember(this);
 202  
         }
 203  
 
 204  
         @Override
 205  
         public String getDelegationMemberId() {
 206  9
             return this.delegationMemberId;
 207  
         }
 208  
 
 209  
         public void setDelegationMemberId(String delegationMemberId) {
 210  2
             if (StringUtils.isEmpty(delegationMemberId)) {
 211  0
                 throw new IllegalArgumentException("delegationMemberId is a required field and cannot be null or blank");
 212  
             }
 213  2
             this.delegationMemberId = delegationMemberId;
 214  2
         }
 215  
 
 216  
         public String getDelegationId() {
 217  9
             return delegationId;
 218  
         }
 219  
 
 220  
         public void setDelegationId(String delegationId) {
 221  2
             this.delegationId = delegationId;
 222  2
         }
 223  
 
 224  
         public String getMemberId() {
 225  9
             return memberId;
 226  
         }
 227  
 
 228  
         public void setMemberId(String memberId) {
 229  2
             this.memberId = memberId;
 230  2
         }
 231  
 
 232  
         public String getRoleMemberId() {
 233  9
             return roleMemberId;
 234  
         }
 235  
 
 236  
         public void setRoleMemberId(String roleMemberId) {
 237  2
             this.roleMemberId = roleMemberId;
 238  2
         }
 239  
 
 240  
         public String getTypeCode() {
 241  9
             return typeCode;
 242  
         }
 243  
 
 244  
         public void setTypeCode(String typeCode) {
 245  2
             this.typeCode = typeCode;
 246  2
         }
 247  
 
 248  
         @Override
 249  
         public Long getVersionNumber() {
 250  9
             return versionNumber;
 251  
         }
 252  
 
 253  
         public void setVersionNumber(Long versionNumber) {
 254  2
             if (versionNumber == null) {
 255  0
                 throw new IllegalArgumentException("versionNumber is required and must be non-null");
 256  
             }
 257  2
             this.versionNumber = versionNumber;
 258  2
         }
 259  
 
 260  
         @Override
 261  
         public Timestamp getActiveFromDate() {
 262  9
             return activeFromDate;
 263  
         }
 264  
 
 265  
         public void setActiveFromDate(Timestamp activeFromDate) {
 266  2
             this.activeFromDate = activeFromDate;
 267  2
         }
 268  
 
 269  
         @Override
 270  
         public Timestamp getActiveToDate() {
 271  9
             return activeToDate;
 272  
         }
 273  
 
 274  
         public void setActiveToDate(Timestamp activeToDate) {
 275  2
             this.activeToDate = activeToDate;
 276  2
         }
 277  
 
 278  
         @Override
 279  
         public boolean isActive(Timestamp activeAsOfDate) {
 280  0
             return (activeFromDate.before(activeAsOfDate) && activeToDate.after(activeAsOfDate));
 281  
         }
 282  
     }
 283  
 
 284  
     /**
 285  
      * Defines some internal constants used on this class.
 286  
      */
 287  0
     static class Constants {
 288  
 
 289  
         final static String ROOT_ELEMENT_NAME = "delegateMember";
 290  
         final static String TYPE_NAME = "DelegateMemberType";
 291  1
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
 292  
 
 293  
     }
 294  
 
 295  
     /**
 296  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 297  
      */
 298  0
     static class Elements {
 299  
         final static String DELEGATION_MEMBER_ID = "delegationMemberId";
 300  
         final static String ROLE_ID = "roleId";
 301  
         final static String DELEGATION_ID = "delegationId";
 302  
         final static String MEMBER_ID = "memberId";
 303  
         final static String ROLE_MEMBER_ID = "roleMemberId";
 304  
         final static String TYPE_CODE = "typeCode";
 305  
     }
 306  
 }