| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.kuali.rice.kim.api.role; |
| 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.w3c.dom.Element; |
| 25 | |
|
| 26 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 27 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 28 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 29 | |
import javax.xml.bind.annotation.XmlElement; |
| 30 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 31 | |
import javax.xml.bind.annotation.XmlType; |
| 32 | |
import java.util.Collection; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
@XmlRootElement(name = RoleResponsibility.Constants.ROOT_ELEMENT_NAME) |
| 41 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 42 | |
@XmlType(name = RoleResponsibility.Constants.TYPE_NAME, propOrder = { |
| 43 | |
RoleResponsibility.Elements.ROLE_RESPONSIBILITY_ID, |
| 44 | |
RoleResponsibility.Elements.ROLE_ID, |
| 45 | |
RoleResponsibility.Elements.RESPONSIBILITY_ID, |
| 46 | |
CoreConstants.CommonElements.ACTIVE, |
| 47 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
| 48 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 49 | |
}) |
| 50 | 5 | final public class RoleResponsibility implements RoleResponsibilityContract, ModelObjectComplete { |
| 51 | |
private static final long serialVersionUID = 1L; |
| 52 | |
|
| 53 | |
@XmlElement(name = RoleResponsibility.Elements.ROLE_RESPONSIBILITY_ID, required = true) |
| 54 | |
private final String roleResponsibilityId; |
| 55 | |
|
| 56 | |
@XmlElement(name = RoleResponsibility.Elements.ROLE_ID) |
| 57 | |
private final String roleId; |
| 58 | |
|
| 59 | |
@XmlElement(name = RoleResponsibility.Elements.RESPONSIBILITY_ID) |
| 60 | |
private final String responsibilityId; |
| 61 | |
|
| 62 | |
@XmlElement(name = CoreConstants.CommonElements.ACTIVE) |
| 63 | |
private final boolean active; |
| 64 | |
|
| 65 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER) |
| 66 | |
private final Long versionNumber; |
| 67 | |
|
| 68 | 10 | @SuppressWarnings("unused") |
| 69 | |
@XmlAnyElement |
| 70 | |
private final Collection<Element> _futureElements = null; |
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
@SuppressWarnings("unused") |
| 77 | 5 | private RoleResponsibility() { |
| 78 | 5 | this.roleResponsibilityId = null; |
| 79 | 5 | this.roleId = null; |
| 80 | 5 | this.responsibilityId = null; |
| 81 | 5 | this.versionNumber = null; |
| 82 | 5 | this.active = false; |
| 83 | 5 | } |
| 84 | |
|
| 85 | 5 | private RoleResponsibility(Builder b) { |
| 86 | 5 | this.roleResponsibilityId = b.getRoleResponsibilityId(); |
| 87 | 5 | this.responsibilityId = b.getResponsibilityId(); |
| 88 | 5 | this.roleId = b.getRoleId(); |
| 89 | 5 | this.active = b.isActive(); |
| 90 | 5 | this.versionNumber = b.getVersionNumber(); |
| 91 | 5 | } |
| 92 | |
|
| 93 | |
@Override |
| 94 | |
public String getResponsibilityId() { |
| 95 | 2 | return this.responsibilityId; |
| 96 | |
} |
| 97 | |
|
| 98 | |
@Override |
| 99 | |
public String getRoleId() { |
| 100 | 2 | return this.roleId; |
| 101 | |
} |
| 102 | |
|
| 103 | |
@Override |
| 104 | |
public String getRoleResponsibilityId() { |
| 105 | 2 | return this.roleResponsibilityId; |
| 106 | |
} |
| 107 | |
|
| 108 | |
@Override |
| 109 | |
public boolean isActive() { |
| 110 | 2 | return this.active; |
| 111 | |
} |
| 112 | |
|
| 113 | |
@Override |
| 114 | |
public Long getVersionNumber() { |
| 115 | 2 | return this.versionNumber; |
| 116 | |
} |
| 117 | |
|
| 118 | |
@Override |
| 119 | |
public int hashCode() { |
| 120 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 121 | |
} |
| 122 | |
|
| 123 | |
@Override |
| 124 | |
public boolean equals(Object obj) { |
| 125 | 4 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 126 | |
} |
| 127 | |
|
| 128 | |
@Override |
| 129 | |
public String toString() { |
| 130 | 0 | return ToStringBuilder.reflectionToString(this); |
| 131 | |
} |
| 132 | |
|
| 133 | 6 | public static class Builder implements RoleResponsibilityContract, ModelBuilder, ModelObjectComplete { |
| 134 | |
private String roleResponsibilityId; |
| 135 | |
private String roleId; |
| 136 | |
private String responsibilityId; |
| 137 | 6 | private boolean active = true; |
| 138 | |
private Long versionNumber; |
| 139 | |
|
| 140 | |
|
| 141 | 6 | private Builder() { |
| 142 | 6 | } |
| 143 | |
|
| 144 | |
public static Builder create() { |
| 145 | 6 | return new Builder(); |
| 146 | |
} |
| 147 | |
|
| 148 | |
public static Builder create(String roleResponsibilityId, String roleId, String responsibilityId) { |
| 149 | 4 | Builder b = create(); |
| 150 | 4 | b.setRoleResponsibilityId(roleResponsibilityId); |
| 151 | 4 | b.setRoleId(roleId); |
| 152 | 4 | b.setResponsibilityId(responsibilityId); |
| 153 | 4 | return b; |
| 154 | |
} |
| 155 | |
|
| 156 | |
public static Builder create(RoleResponsibilityContract rrContract) { |
| 157 | 1 | Builder b = create(); |
| 158 | 1 | b.setRoleResponsibilityId(rrContract.getRoleResponsibilityId()); |
| 159 | 1 | b.setResponsibilityId(rrContract.getResponsibilityId()); |
| 160 | 1 | b.setRoleId(rrContract.getRoleId()); |
| 161 | 1 | b.setActive(rrContract.isActive()); |
| 162 | 1 | b.setVersionNumber(rrContract.getVersionNumber()); |
| 163 | 1 | return b; |
| 164 | |
} |
| 165 | |
|
| 166 | |
@Override |
| 167 | |
public RoleResponsibility build() { |
| 168 | 6 | if (versionNumber == null || roleResponsibilityId == null) { |
| 169 | 1 | throw new IllegalStateException( |
| 170 | |
"versionNumber and roleResponsibilityId must be non-null for a RoleResponsibility object"); |
| 171 | |
} |
| 172 | 5 | return new RoleResponsibility(this); |
| 173 | |
} |
| 174 | |
|
| 175 | |
@Override |
| 176 | |
public String getRoleResponsibilityId() { |
| 177 | 5 | return roleResponsibilityId; |
| 178 | |
} |
| 179 | |
|
| 180 | |
public void setRoleResponsibilityId(String roleResponsibilityId) { |
| 181 | 6 | if (StringUtils.isBlank(roleResponsibilityId)) { |
| 182 | 0 | throw new IllegalArgumentException("roleResponsibilityId cannot be blank or null"); |
| 183 | |
} |
| 184 | 6 | this.roleResponsibilityId = roleResponsibilityId; |
| 185 | 6 | } |
| 186 | |
|
| 187 | |
@Override |
| 188 | |
public String getRoleId() { |
| 189 | 5 | return roleId; |
| 190 | |
} |
| 191 | |
|
| 192 | |
public void setRoleId(String roleId) { |
| 193 | 6 | this.roleId = roleId; |
| 194 | 6 | } |
| 195 | |
|
| 196 | |
@Override |
| 197 | |
public String getResponsibilityId() { |
| 198 | 5 | return responsibilityId; |
| 199 | |
} |
| 200 | |
|
| 201 | |
public void setResponsibilityId(String responsibilityId) { |
| 202 | 6 | this.responsibilityId = responsibilityId; |
| 203 | 6 | } |
| 204 | |
|
| 205 | |
|
| 206 | |
@Override |
| 207 | |
public boolean isActive() { |
| 208 | 5 | return active; |
| 209 | |
} |
| 210 | |
|
| 211 | |
public void setActive(boolean active) { |
| 212 | 2 | this.active = active; |
| 213 | 2 | } |
| 214 | |
|
| 215 | |
@Override |
| 216 | |
public Long getVersionNumber() { |
| 217 | 5 | return versionNumber; |
| 218 | |
} |
| 219 | |
|
| 220 | |
public void setVersionNumber(Long versionNumber) { |
| 221 | 5 | if (versionNumber == null) { |
| 222 | 0 | throw new IllegalArgumentException("versionNumber must be non-null"); |
| 223 | |
} |
| 224 | 5 | this.versionNumber = versionNumber; |
| 225 | 5 | } |
| 226 | |
|
| 227 | |
@Override |
| 228 | |
public int hashCode() { |
| 229 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 230 | |
} |
| 231 | |
|
| 232 | |
@Override |
| 233 | |
public boolean equals(Object obj) { |
| 234 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 235 | |
} |
| 236 | |
|
| 237 | |
@Override |
| 238 | |
public String toString() { |
| 239 | 0 | return ToStringBuilder.reflectionToString(this); |
| 240 | |
} |
| 241 | |
} |
| 242 | |
|
| 243 | |
|
| 244 | |
|
| 245 | |
|
| 246 | |
|
| 247 | 0 | static class Elements { |
| 248 | |
final static String ROLE_RESPONSIBILITY_ID = "roleResponsibilityId"; |
| 249 | |
final static String ROLE_ID = "roleId"; |
| 250 | |
final static String RESPONSIBILITY_ID = "responsibilityId"; |
| 251 | |
} |
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
|
| 256 | 0 | static class Constants { |
| 257 | |
final static String ROOT_ELEMENT_NAME = "roleResponsibility"; |
| 258 | |
final static String TYPE_NAME = "RoleResponsibilityType"; |
| 259 | 1 | final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS}; |
| 260 | |
} |
| 261 | |
} |