1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kim.api.group; |
18 | |
|
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
21 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
22 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
23 | |
import org.kuali.rice.core.api.CoreConstants; |
24 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
25 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
26 | |
import org.kuali.rice.core.jaxb.SqlTimestampAdapter; |
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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
36 | |
import java.io.Serializable; |
37 | |
import java.sql.Timestamp; |
38 | |
import java.util.Collection; |
39 | |
|
40 | |
@XmlRootElement(name = GroupMember.Constants.ROOT_ELEMENT_NAME) |
41 | |
@XmlAccessorType(XmlAccessType.NONE) |
42 | |
@XmlType(name = GroupMember.Constants.TYPE_NAME, propOrder = { |
43 | |
GroupMember.Elements.ID, |
44 | |
GroupMember.Elements.GROUP_ID, |
45 | |
GroupMember.Elements.MEMBER_ID, |
46 | |
GroupMember.Elements.TYPE_CODE, |
47 | |
CoreConstants.CommonElements.ACTIVE_FROM_DATE, |
48 | |
CoreConstants.CommonElements.ACTIVE_TO_DATE, |
49 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
50 | |
CoreConstants.CommonElements.OBJECT_ID, |
51 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
52 | |
}) |
53 | |
public class GroupMember implements GroupMemberContract, ModelObjectComplete { |
54 | |
|
55 | |
@XmlElement(name = Elements.ID, required = true) |
56 | |
private final String id; |
57 | |
|
58 | |
@XmlElement(name = Elements.GROUP_ID, required = true) |
59 | |
private final String groupId; |
60 | |
|
61 | |
@XmlElement(name = Elements.MEMBER_ID, required = true) |
62 | |
private final String memberId; |
63 | |
|
64 | |
@XmlElement(name = Elements.TYPE_CODE, required = true) |
65 | |
private final String typeCode; |
66 | |
|
67 | |
@XmlElement(name = CoreConstants.CommonElements.ACTIVE_FROM_DATE, required = false) |
68 | |
@XmlJavaTypeAdapter(SqlTimestampAdapter.class) |
69 | |
private final Timestamp activeFromDate; |
70 | |
|
71 | |
@XmlElement(name = CoreConstants.CommonElements.ACTIVE_TO_DATE, required = false) |
72 | |
@XmlJavaTypeAdapter(SqlTimestampAdapter.class) |
73 | |
private final Timestamp activeToDate; |
74 | |
|
75 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
76 | |
private final Long versionNumber; |
77 | |
|
78 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
79 | |
private final String objectId; |
80 | |
|
81 | 14 | @SuppressWarnings("unused") |
82 | |
@XmlAnyElement |
83 | |
private final Collection<Element> _futureElements = null; |
84 | |
|
85 | 9 | private GroupMember() { |
86 | 9 | this.id = null; |
87 | 9 | this.groupId = null; |
88 | 9 | this.memberId = null; |
89 | 9 | this.typeCode = null; |
90 | 9 | this.versionNumber = null; |
91 | 9 | this.objectId = null; |
92 | 9 | this.activeFromDate = null; |
93 | 9 | this.activeToDate = null; |
94 | 9 | } |
95 | |
|
96 | |
|
97 | 5 | public GroupMember(Builder builder) { |
98 | 5 | this.id = builder.getId(); |
99 | 5 | this.groupId = builder.getGroupId(); |
100 | 5 | this.memberId = builder.getMemberId(); |
101 | 5 | this.typeCode = builder.getTypeCode(); |
102 | 5 | this.versionNumber = builder.getVersionNumber(); |
103 | 5 | this.objectId = builder.getObjectId(); |
104 | 5 | this.activeFromDate = builder.getActiveFromDate(); |
105 | 5 | this.activeToDate = builder.getActiveToDate(); |
106 | 5 | } |
107 | |
|
108 | 3 | public static class Builder implements GroupMemberContract, ModelBuilder, Serializable { |
109 | |
private String id; |
110 | |
private String groupId; |
111 | |
private String memberId; |
112 | |
private String typeCode; |
113 | |
private Timestamp activeFromDate; |
114 | |
private Timestamp activeToDate; |
115 | |
private Long versionNumber; |
116 | |
private String objectId; |
117 | |
|
118 | 5 | private Builder(String id, String groupId, String memberId, String typeCode) { |
119 | 5 | setId(id); |
120 | 5 | setGroupId(groupId); |
121 | 5 | setMemberId(memberId); |
122 | 5 | setTypeCode(typeCode); |
123 | 5 | } |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
public static Builder create(String id, String groupId, String memberId, String typeCode) { |
129 | 0 | return new Builder(id, groupId, memberId, typeCode); |
130 | |
} |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
public static Builder create(GroupMemberContract contract) { |
136 | 5 | Builder builder = new Builder(contract.getId(), contract.getGroupId(), contract.getMemberId(), contract.getTypeCode()); |
137 | 5 | builder.setActiveFromDate(contract.getActiveFromDate()); |
138 | 5 | builder.setActiveToDate(contract.getActiveToDate()); |
139 | 5 | builder.setVersionNumber(contract.getVersionNumber()); |
140 | 5 | builder.setObjectId(contract.getObjectId()); |
141 | 5 | return builder; |
142 | |
} |
143 | |
|
144 | |
@Override |
145 | |
public String getId() { |
146 | 5 | return id; |
147 | |
} |
148 | |
|
149 | |
public void setId(final String id) { |
150 | 5 | if (StringUtils.isEmpty(id)) { |
151 | 0 | throw new IllegalArgumentException("id is blank"); |
152 | |
} |
153 | 5 | this.id = id; |
154 | 5 | } |
155 | |
|
156 | |
@Override |
157 | |
public String getGroupId() { |
158 | 5 | return groupId; |
159 | |
} |
160 | |
|
161 | |
public void setGroupId(final String groupId) { |
162 | 5 | if (StringUtils.isEmpty(id)) { |
163 | 0 | throw new IllegalArgumentException("groupId is blank"); |
164 | |
} |
165 | 5 | this.groupId = groupId; |
166 | 5 | } |
167 | |
|
168 | |
@Override |
169 | |
public String getMemberId() { |
170 | 5 | return memberId; |
171 | |
} |
172 | |
|
173 | |
public void setMemberId(final String memberId) { |
174 | 5 | if (StringUtils.isEmpty(id)) { |
175 | 0 | throw new IllegalArgumentException("memberId is blank"); |
176 | |
} |
177 | 5 | this.memberId = memberId; |
178 | 5 | } |
179 | |
|
180 | |
@Override |
181 | |
public String getTypeCode() { |
182 | 5 | return typeCode; |
183 | |
} |
184 | |
|
185 | |
public void setTypeCode(final String typeCode) { |
186 | 5 | if (StringUtils.isEmpty(id)) { |
187 | 0 | throw new IllegalArgumentException("typeCode is blank"); |
188 | |
} |
189 | 5 | this.typeCode = typeCode; |
190 | 5 | } |
191 | |
|
192 | |
@Override |
193 | |
public Timestamp getActiveFromDate() { |
194 | 5 | return activeFromDate; |
195 | |
} |
196 | |
|
197 | |
public void setActiveFromDate(final Timestamp activeFromDate) { |
198 | 5 | this.activeFromDate = activeFromDate; |
199 | 5 | } |
200 | |
|
201 | |
@Override |
202 | |
public Timestamp getActiveToDate() { |
203 | 5 | return activeToDate; |
204 | |
} |
205 | |
|
206 | |
public void setActiveToDate(final Timestamp activeToDate) { |
207 | 5 | this.activeToDate = activeToDate; |
208 | 5 | } |
209 | |
|
210 | |
@Override |
211 | |
public Long getVersionNumber() { |
212 | 5 | return versionNumber; |
213 | |
} |
214 | |
|
215 | |
public void setVersionNumber(final Long versionNumber) { |
216 | 5 | this.versionNumber = versionNumber; |
217 | 5 | } |
218 | |
|
219 | |
@Override |
220 | |
public String getObjectId() { |
221 | 5 | return objectId; |
222 | |
} |
223 | |
|
224 | |
public void setObjectId(final String objectId) { |
225 | 5 | this.objectId = objectId; |
226 | 5 | } |
227 | |
|
228 | |
@Override |
229 | |
public GroupMember build() { |
230 | 5 | return new GroupMember(this); |
231 | |
} |
232 | |
} |
233 | |
|
234 | |
public String getId() { |
235 | 5 | return id; |
236 | |
} |
237 | |
|
238 | |
public String getGroupId() { |
239 | 5 | return groupId; |
240 | |
} |
241 | |
|
242 | |
public String getMemberId() { |
243 | 5 | return memberId; |
244 | |
} |
245 | |
|
246 | |
public String getTypeCode() { |
247 | 5 | return typeCode; |
248 | |
} |
249 | |
|
250 | |
public Timestamp getActiveFromDate() { |
251 | 5 | return activeFromDate; |
252 | |
} |
253 | |
|
254 | |
public Timestamp getActiveToDate() { |
255 | 5 | return activeToDate; |
256 | |
} |
257 | |
|
258 | |
public Long getVersionNumber() { |
259 | 5 | return versionNumber; |
260 | |
} |
261 | |
|
262 | |
public String getObjectId() { |
263 | 5 | return objectId; |
264 | |
} |
265 | |
|
266 | |
@Override |
267 | |
public int hashCode() { |
268 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
269 | |
} |
270 | |
|
271 | |
@Override |
272 | |
public boolean equals(Object obj) { |
273 | 3 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
274 | |
} |
275 | |
|
276 | |
@Override |
277 | |
public String toString() { |
278 | 0 | return ToStringBuilder.reflectionToString(this); |
279 | |
} |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | 0 | static class Constants { |
285 | |
final static String ROOT_ELEMENT_NAME = "groupMember"; |
286 | |
final static String TYPE_NAME = "GroupMemberType"; |
287 | 1 | final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS}; |
288 | |
} |
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | 0 | static class Elements { |
295 | |
final static String ID = "id"; |
296 | |
final static String GROUP_ID = "groupId"; |
297 | |
final static String MEMBER_ID = "memberId"; |
298 | |
final static String TYPE_CODE = "typeCode"; |
299 | |
} |
300 | |
} |