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