1 | |
package org.kuali.rice.kim.api.identity.affiliation; |
2 | |
|
3 | |
import java.io.Serializable; |
4 | |
import java.util.Collection; |
5 | |
import javax.xml.bind.annotation.XmlAccessType; |
6 | |
import javax.xml.bind.annotation.XmlAccessorType; |
7 | |
import javax.xml.bind.annotation.XmlAnyElement; |
8 | |
import javax.xml.bind.annotation.XmlElement; |
9 | |
import javax.xml.bind.annotation.XmlRootElement; |
10 | |
import javax.xml.bind.annotation.XmlType; |
11 | |
|
12 | |
import org.apache.commons.lang.StringUtils; |
13 | |
import org.kuali.rice.core.api.CoreConstants; |
14 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
15 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
16 | |
import org.w3c.dom.Element; |
17 | |
|
18 | 34 | @XmlRootElement(name = EntityAffiliation.Constants.ROOT_ELEMENT_NAME) |
19 | |
@XmlAccessorType(XmlAccessType.NONE) |
20 | |
@XmlType(name = EntityAffiliation.Constants.TYPE_NAME, propOrder = { |
21 | |
EntityAffiliation.Elements.ID, |
22 | |
EntityAffiliation.Elements.ENTITY_ID, |
23 | |
EntityAffiliation.Elements.AFFILIATION_TYPE, |
24 | |
EntityAffiliation.Elements.CAMPUS_CODE, |
25 | |
EntityAffiliation.Elements.DEFAULT_VALUE, |
26 | |
EntityAffiliation.Elements.ACTIVE, |
27 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
28 | |
CoreConstants.CommonElements.OBJECT_ID, |
29 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
30 | |
}) |
31 | 16 | public final class EntityAffiliation extends AbstractDataTransferObject |
32 | |
implements EntityAffiliationContract |
33 | |
{ |
34 | |
|
35 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
36 | |
private final String entityId; |
37 | |
@XmlElement(name = Elements.AFFILIATION_TYPE, required = false) |
38 | |
private final EntityAffiliationType affiliationType; |
39 | |
@XmlElement(name = Elements.CAMPUS_CODE, required = false) |
40 | |
private final String campusCode; |
41 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
42 | |
private final Long versionNumber; |
43 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
44 | |
private final String objectId; |
45 | |
@XmlElement(name = Elements.DEFAULT_VALUE, required = false) |
46 | |
private final boolean defaultValue; |
47 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
48 | |
private final boolean active; |
49 | |
@XmlElement(name = Elements.ID, required = false) |
50 | |
private final String id; |
51 | 26 | @SuppressWarnings("unused") |
52 | |
@XmlAnyElement |
53 | |
private final Collection<Element> _futureElements = null; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 10 | private EntityAffiliation() { |
60 | 10 | this.entityId = null; |
61 | 10 | this.affiliationType = null; |
62 | 10 | this.campusCode = null; |
63 | 10 | this.versionNumber = null; |
64 | 10 | this.objectId = null; |
65 | 10 | this.defaultValue = false; |
66 | 10 | this.active = false; |
67 | 10 | this.id = null; |
68 | 10 | } |
69 | |
|
70 | 16 | private EntityAffiliation(Builder builder) { |
71 | 16 | this.entityId = builder.getEntityId(); |
72 | 16 | this.affiliationType = builder.getAffiliationType() != null ? builder.getAffiliationType().build() : null; |
73 | 16 | this.campusCode = builder.getCampusCode(); |
74 | 16 | this.versionNumber = builder.getVersionNumber(); |
75 | 16 | this.objectId = builder.getObjectId(); |
76 | 16 | this.defaultValue = builder.isDefaultValue(); |
77 | 16 | this.active = builder.isActive(); |
78 | 16 | this.id = builder.getId(); |
79 | 16 | } |
80 | |
|
81 | |
@Override |
82 | |
public String getEntityId() { |
83 | 10 | return this.entityId; |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public EntityAffiliationType getAffiliationType() { |
88 | 34 | return this.affiliationType; |
89 | |
} |
90 | |
|
91 | |
@Override |
92 | |
public String getCampusCode() { |
93 | 10 | return this.campusCode; |
94 | |
} |
95 | |
|
96 | |
@Override |
97 | |
public Long getVersionNumber() { |
98 | 10 | return this.versionNumber; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public String getObjectId() { |
103 | 10 | return this.objectId; |
104 | |
} |
105 | |
|
106 | |
@Override |
107 | |
public boolean isDefaultValue() { |
108 | 10 | return this.defaultValue; |
109 | |
} |
110 | |
|
111 | |
@Override |
112 | |
public boolean isActive() { |
113 | 10 | return this.active; |
114 | |
} |
115 | |
|
116 | |
@Override |
117 | |
public String getId() { |
118 | 10 | return this.id; |
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | 8 | public final static class Builder |
126 | |
implements Serializable, ModelBuilder, EntityAffiliationContract |
127 | |
{ |
128 | |
|
129 | |
private String entityId; |
130 | |
private EntityAffiliationType.Builder affiliationType; |
131 | |
private String campusCode; |
132 | |
private Long versionNumber; |
133 | |
private String objectId; |
134 | |
private boolean defaultValue; |
135 | |
private boolean active; |
136 | |
private String id; |
137 | |
|
138 | 16 | private Builder() { } |
139 | |
|
140 | |
public static Builder create() { |
141 | 16 | return new Builder(); |
142 | |
} |
143 | |
|
144 | |
public static Builder create(EntityAffiliationContract contract) { |
145 | 13 | if (contract == null) { |
146 | 0 | throw new IllegalArgumentException("contract was null"); |
147 | |
} |
148 | 13 | Builder builder = create(); |
149 | 13 | builder.setEntityId(contract.getEntityId()); |
150 | 13 | if (contract.getAffiliationType() != null) { |
151 | 12 | builder.setAffiliationType(EntityAffiliationType.Builder.create(contract.getAffiliationType())); |
152 | |
} |
153 | 13 | builder.setCampusCode(contract.getCampusCode()); |
154 | 13 | builder.setVersionNumber(contract.getVersionNumber()); |
155 | 13 | builder.setObjectId(contract.getObjectId()); |
156 | 13 | builder.setDefaultValue(contract.isDefaultValue()); |
157 | 13 | builder.setActive(contract.isActive()); |
158 | 13 | builder.setId(contract.getId()); |
159 | 13 | return builder; |
160 | |
} |
161 | |
|
162 | |
public EntityAffiliation build() { |
163 | 16 | return new EntityAffiliation(this); |
164 | |
} |
165 | |
|
166 | |
@Override |
167 | |
public String getEntityId() { |
168 | 16 | return this.entityId; |
169 | |
} |
170 | |
|
171 | |
@Override |
172 | |
public EntityAffiliationType.Builder getAffiliationType() { |
173 | 30 | return this.affiliationType; |
174 | |
} |
175 | |
|
176 | |
@Override |
177 | |
public String getCampusCode() { |
178 | 16 | return this.campusCode; |
179 | |
} |
180 | |
|
181 | |
@Override |
182 | |
public Long getVersionNumber() { |
183 | 16 | return this.versionNumber; |
184 | |
} |
185 | |
|
186 | |
@Override |
187 | |
public String getObjectId() { |
188 | 16 | return this.objectId; |
189 | |
} |
190 | |
|
191 | |
@Override |
192 | |
public boolean isDefaultValue() { |
193 | 20 | return this.defaultValue; |
194 | |
} |
195 | |
|
196 | |
@Override |
197 | |
public boolean isActive() { |
198 | 20 | return this.active; |
199 | |
} |
200 | |
|
201 | |
@Override |
202 | |
public String getId() { |
203 | 16 | return this.id; |
204 | |
} |
205 | |
|
206 | |
public void setEntityId(String entityId) { |
207 | 13 | this.entityId = entityId; |
208 | 13 | } |
209 | |
|
210 | |
public void setAffiliationType(EntityAffiliationType.Builder affiliationType) { |
211 | 12 | this.affiliationType = affiliationType; |
212 | 12 | } |
213 | |
|
214 | |
public void setCampusCode(String campusCode) { |
215 | 13 | this.campusCode = campusCode; |
216 | 13 | } |
217 | |
|
218 | |
public void setVersionNumber(Long versionNumber) { |
219 | 13 | this.versionNumber = versionNumber; |
220 | 13 | } |
221 | |
|
222 | |
public void setObjectId(String objectId) { |
223 | 13 | this.objectId = objectId; |
224 | 13 | } |
225 | |
|
226 | |
public void setDefaultValue(boolean defaultValue) { |
227 | 13 | this.defaultValue = defaultValue; |
228 | 13 | } |
229 | |
|
230 | |
public void setActive(boolean active) { |
231 | 13 | this.active = active; |
232 | 13 | } |
233 | |
|
234 | |
public void setId(String id) { |
235 | 14 | if (StringUtils.isWhitespace(id)) { |
236 | 1 | throw new IllegalArgumentException("id is blank"); |
237 | |
} |
238 | 13 | this.id = id; |
239 | 13 | } |
240 | |
|
241 | |
} |
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | 0 | static class Constants { |
249 | |
|
250 | |
final static String ROOT_ELEMENT_NAME = "entityAffiliation"; |
251 | |
final static String TYPE_NAME = "EntityAffiliationType"; |
252 | |
} |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | 0 | static class Elements { |
260 | |
|
261 | |
final static String ENTITY_ID = "entityId"; |
262 | |
final static String AFFILIATION_TYPE = "affiliationType"; |
263 | |
final static String CAMPUS_CODE = "campusCode"; |
264 | |
final static String DEFAULT_VALUE = "defaultValue"; |
265 | |
final static String ACTIVE = "active"; |
266 | |
final static String ID = "id"; |
267 | |
|
268 | |
} |
269 | |
|
270 | |
} |