Coverage Report - org.kuali.rice.kim.api.role.RoleResponsibility
 
Classes in this File Line Coverage Branch Coverage Complexity
RoleResponsibility
0%
0/21
N/A
1.28
RoleResponsibility$1
N/A
N/A
1.28
RoleResponsibility$Builder
0%
0/42
0%
0/8
1.28
RoleResponsibility$Cache
0%
0/1
N/A
1.28
RoleResponsibility$Constants
0%
0/1
N/A
1.28
RoleResponsibility$Elements
0%
0/1
N/A
1.28
 
 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.role;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.commons.lang.builder.EqualsBuilder;
 20  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 21  
 import org.apache.commons.lang.builder.ToStringBuilder;
 22  
 import org.kuali.rice.core.api.CoreConstants;
 23  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 24  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 25  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 26  
 import org.kuali.rice.kim.api.KimConstants;
 27  
 import org.w3c.dom.Element;
 28  
 
 29  
 import javax.xml.bind.annotation.XmlAccessType;
 30  
 import javax.xml.bind.annotation.XmlAccessorType;
 31  
 import javax.xml.bind.annotation.XmlAnyElement;
 32  
 import javax.xml.bind.annotation.XmlElement;
 33  
 import javax.xml.bind.annotation.XmlRootElement;
 34  
 import javax.xml.bind.annotation.XmlType;
 35  
 import java.util.Collection;
 36  
 
 37  
 /**
 38  
  * An lightweight association of a Responsibility and a Role represented by references to the identifiers of a
 39  
  * Role and a Responsibility that are related to each other.
 40  
  *
 41  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 42  
  */
 43  
 @XmlRootElement(name = RoleResponsibility.Constants.ROOT_ELEMENT_NAME)
 44  
 @XmlAccessorType(XmlAccessType.NONE)
 45  
 @XmlType(name = RoleResponsibility.Constants.TYPE_NAME, propOrder = {
 46  
         RoleResponsibility.Elements.ROLE_RESPONSIBILITY_ID,
 47  
         RoleResponsibility.Elements.ROLE_ID,
 48  
         RoleResponsibility.Elements.RESPONSIBILITY_ID,
 49  
         CoreConstants.CommonElements.ACTIVE,
 50  
         CoreConstants.CommonElements.VERSION_NUMBER,
 51  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 52  
 })
 53  0
 final public class RoleResponsibility extends AbstractDataTransferObject implements RoleResponsibilityContract {
 54  
     private static final long serialVersionUID = 1L;
 55  
 
 56  
     @XmlElement(name = RoleResponsibility.Elements.ROLE_RESPONSIBILITY_ID, required = true)
 57  
     private final String roleResponsibilityId;
 58  
 
 59  
     @XmlElement(name = RoleResponsibility.Elements.ROLE_ID)
 60  
     private final String roleId;
 61  
 
 62  
     @XmlElement(name = RoleResponsibility.Elements.RESPONSIBILITY_ID)
 63  
     private final String responsibilityId;
 64  
 
 65  
     @XmlElement(name = CoreConstants.CommonElements.ACTIVE)
 66  
     private final boolean active;
 67  
 
 68  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER)
 69  
     private final Long versionNumber;
 70  
 
 71  0
     @SuppressWarnings("unused")
 72  
     @XmlAnyElement
 73  
     private final Collection<Element> _futureElements = null;
 74  
 
 75  
 
 76  
     /**
 77  
      * This constructor should never be called except during JAXB unmarshalling.
 78  
      */
 79  
     @SuppressWarnings("unused")
 80  0
     private RoleResponsibility() {
 81  0
         this.roleResponsibilityId = null;
 82  0
         this.roleId = null;
 83  0
         this.responsibilityId = null;
 84  0
         this.versionNumber = null;
 85  0
         this.active = false;
 86  0
     }
 87  
 
 88  0
     private RoleResponsibility(Builder b) {
 89  0
         this.roleResponsibilityId = b.getRoleResponsibilityId();
 90  0
         this.responsibilityId = b.getResponsibilityId();
 91  0
         this.roleId = b.getRoleId();
 92  0
         this.active = b.isActive();
 93  0
         this.versionNumber = b.getVersionNumber();
 94  0
     }
 95  
 
 96  
     @Override
 97  
     public String getResponsibilityId() {
 98  0
         return this.responsibilityId;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public String getRoleId() {
 103  0
         return this.roleId;
 104  
     }
 105  
 
 106  
     @Override
 107  
     public String getRoleResponsibilityId() {
 108  0
         return this.roleResponsibilityId;
 109  
     }
 110  
 
 111  
     @Override
 112  
     public boolean isActive() {
 113  0
         return this.active;
 114  
     }
 115  
 
 116  
     @Override
 117  
     public Long getVersionNumber() {
 118  0
         return this.versionNumber;
 119  
     }
 120  
 
 121  0
     public static class Builder implements RoleResponsibilityContract, ModelBuilder, ModelObjectComplete {
 122  
         private String roleResponsibilityId;
 123  
         private String roleId;
 124  
         private String responsibilityId;
 125  0
         private boolean active = true;
 126  
         private Long versionNumber;
 127  
 
 128  
 
 129  0
         private Builder() {
 130  0
         }
 131  
 
 132  
         public static Builder create() {
 133  0
             return new Builder();
 134  
         }
 135  
 
 136  
         public static Builder create(String roleResponsibilityId, String roleId, String responsibilityId) {
 137  0
             Builder b = create();
 138  0
             b.setRoleResponsibilityId(roleResponsibilityId);
 139  0
             b.setRoleId(roleId);
 140  0
             b.setResponsibilityId(responsibilityId);
 141  0
             return b;
 142  
         }
 143  
 
 144  
         public static Builder create(RoleResponsibilityContract rrContract) {
 145  0
             Builder b = create();
 146  0
             b.setRoleResponsibilityId(rrContract.getRoleResponsibilityId());
 147  0
             b.setResponsibilityId(rrContract.getResponsibilityId());
 148  0
             b.setRoleId(rrContract.getRoleId());
 149  0
             b.setActive(rrContract.isActive());
 150  0
             b.setVersionNumber(rrContract.getVersionNumber());
 151  0
             return b;
 152  
         }
 153  
 
 154  
         @Override
 155  
         public RoleResponsibility build() {
 156  0
             if (versionNumber == null || roleResponsibilityId == null) {
 157  0
                 throw new IllegalStateException(
 158  
                         "versionNumber and roleResponsibilityId must be non-null for a RoleResponsibility object");
 159  
             }
 160  0
             return new RoleResponsibility(this);
 161  
         }
 162  
 
 163  
         @Override
 164  
         public String getRoleResponsibilityId() {
 165  0
             return roleResponsibilityId;
 166  
         }
 167  
 
 168  
         public void setRoleResponsibilityId(String roleResponsibilityId) {
 169  0
             if (StringUtils.isBlank(roleResponsibilityId)) {
 170  0
                 throw new IllegalArgumentException("roleResponsibilityId cannot be blank or null");
 171  
             }
 172  0
             this.roleResponsibilityId = roleResponsibilityId;
 173  0
         }
 174  
 
 175  
         @Override
 176  
         public String getRoleId() {
 177  0
             return roleId;
 178  
         }
 179  
 
 180  
         public void setRoleId(String roleId) {
 181  0
             this.roleId = roleId;
 182  0
         }
 183  
 
 184  
         @Override
 185  
         public String getResponsibilityId() {
 186  0
             return responsibilityId;
 187  
         }
 188  
 
 189  
         public void setResponsibilityId(String responsibilityId) {
 190  0
             this.responsibilityId = responsibilityId;
 191  0
         }
 192  
 
 193  
 
 194  
         @Override
 195  
         public boolean isActive() {
 196  0
             return active;
 197  
         }
 198  
 
 199  
         public void setActive(boolean active) {
 200  0
             this.active = active;
 201  0
         }
 202  
 
 203  
         @Override
 204  
         public Long getVersionNumber() {
 205  0
             return versionNumber;
 206  
         }
 207  
 
 208  
         public void setVersionNumber(Long versionNumber) {
 209  0
             if (versionNumber == null) {
 210  0
                 throw new IllegalArgumentException("versionNumber must be non-null");
 211  
             }
 212  0
             this.versionNumber = versionNumber;
 213  0
         }
 214  
 
 215  
         @Override
 216  
         public int hashCode() {
 217  0
             return HashCodeBuilder.reflectionHashCode(this);
 218  
         }
 219  
 
 220  
         @Override
 221  
         public boolean equals(Object obj) {
 222  0
             return EqualsBuilder.reflectionEquals(obj, this);
 223  
         }
 224  
 
 225  
         @Override
 226  
         public String toString() {
 227  0
             return ToStringBuilder.reflectionToString(this);
 228  
         }
 229  
     }
 230  
 
 231  
     /**
 232  
      * A private class which exposes constants which define the XML element names to use
 233  
      * when this object is marshalled to XML.
 234  
      */
 235  0
     static class Elements {
 236  
         final static String ROLE_RESPONSIBILITY_ID = "roleResponsibilityId";
 237  
         final static String ROLE_ID = "roleId";
 238  
         final static String RESPONSIBILITY_ID = "responsibilityId";
 239  
     }
 240  
 
 241  
     /**
 242  
      * Defines some internal constants used on this class.
 243  
      */
 244  0
     static class Constants {
 245  
         final static String ROOT_ELEMENT_NAME = "roleResponsibility";
 246  
         final static String TYPE_NAME = "RoleResponsibilityType";
 247  
     }
 248  
 
 249  0
     public static class Cache {
 250  
         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + RoleResponsibility.Constants.TYPE_NAME;
 251  
     }
 252  
 }