1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.api.repository.category; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.CoreConstants; |
20 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
21 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
22 | |
import org.w3c.dom.Element; |
23 | |
|
24 | |
import javax.xml.bind.annotation.XmlAccessType; |
25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
26 | |
import javax.xml.bind.annotation.XmlAnyElement; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlRootElement; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
import java.io.Serializable; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
@XmlRootElement(name = CategoryDefinition.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = CategoryDefinition.Constants.TYPE_NAME, propOrder = { |
36 | |
CategoryDefinition.Elements.ID, |
37 | |
CategoryDefinition.Elements.NAME, |
38 | |
CategoryDefinition.Elements.NAMESPACE, |
39 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
40 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
41 | |
}) |
42 | 0 | public class CategoryDefinition extends AbstractDataTransferObject implements CategoryDefinitionContract { |
43 | |
|
44 | |
private static final long serialVersionUID = -4748818967880857017L; |
45 | |
|
46 | |
@XmlElement(name = Elements.ID, required=true) |
47 | |
private final String id; |
48 | |
@XmlElement(name = Elements.NAME, required=true) |
49 | |
private final String name; |
50 | |
@XmlElement(name = Elements.NAMESPACE, required=true) |
51 | |
private final String namespace; |
52 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
53 | |
private final Long versionNumber; |
54 | |
|
55 | 0 | @SuppressWarnings("unused") |
56 | |
@XmlAnyElement |
57 | |
private final Collection<Element> _futureElements = null; |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | 0 | private CategoryDefinition() { |
63 | 0 | this.id = null; |
64 | 0 | this.name = null; |
65 | 0 | this.namespace = null; |
66 | 0 | this.versionNumber = null; |
67 | 0 | } |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | 0 | private CategoryDefinition(Builder builder) { |
76 | 0 | this.id = builder.getId(); |
77 | 0 | this.name = builder.getName(); |
78 | 0 | this.namespace = builder.getNamespace(); |
79 | 0 | this.versionNumber = builder.getVersionNumber(); |
80 | 0 | } |
81 | |
|
82 | |
public String getId() { |
83 | 0 | return this.id; |
84 | |
} |
85 | |
|
86 | |
public String getName() { |
87 | 0 | return this.name; |
88 | |
} |
89 | |
|
90 | |
public String getNamespace() { |
91 | 0 | return this.namespace; |
92 | |
} |
93 | |
|
94 | |
@Override |
95 | |
public Long getVersionNumber() { |
96 | 0 | return versionNumber; |
97 | |
} |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | 0 | public static class Builder implements CategoryDefinitionContract, ModelBuilder, Serializable { |
103 | |
|
104 | |
private static final long serialVersionUID = -5775478956373560840L; |
105 | |
|
106 | |
private String id; |
107 | |
private String name; |
108 | |
private String namespace; |
109 | |
private Long versionNumber; |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | 0 | private Builder(String id, String name, String namespace) { |
115 | 0 | setId(id); |
116 | 0 | setName(name); |
117 | 0 | setNamespace(namespace); |
118 | 0 | } |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public static Builder create(String id, String name, String namespace) { |
130 | 0 | return new Builder(id, name, namespace); |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
public static Builder create(CategoryDefinitionContract category) { |
140 | 0 | if (category == null) { |
141 | 0 | throw new IllegalArgumentException("contract is null"); |
142 | |
} |
143 | 0 | Builder builder = new Builder(category.getId(), category.getName(), category.getNamespace()); |
144 | 0 | builder.setVersionNumber(category.getVersionNumber()); |
145 | 0 | return builder; |
146 | |
} |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public void setId(String id) { |
155 | 0 | if (null != id && StringUtils.isBlank(id)) { |
156 | 0 | throw new IllegalArgumentException("id must be null or non-blank"); |
157 | |
} |
158 | 0 | this.id = id; |
159 | 0 | } |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public void setName(String name) { |
170 | 0 | if (StringUtils.isBlank(name)) { |
171 | 0 | throw new IllegalArgumentException("name is blank"); |
172 | |
} |
173 | 0 | this.name = name; |
174 | 0 | } |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
public void setNamespace(String namespace) { |
185 | 0 | if (StringUtils.isBlank(namespace)) { |
186 | 0 | throw new IllegalArgumentException("namespace is blank"); |
187 | |
} |
188 | 0 | this.namespace = namespace; |
189 | 0 | } |
190 | |
|
191 | |
public void setVersionNumber(Long versionNumber){ |
192 | 0 | this.versionNumber = versionNumber; |
193 | 0 | } |
194 | |
|
195 | |
@Override |
196 | |
public String getId() { |
197 | 0 | return this.id; |
198 | |
} |
199 | |
|
200 | |
@Override |
201 | |
public String getName() { |
202 | 0 | return this.name; |
203 | |
} |
204 | |
|
205 | |
@Override |
206 | |
public String getNamespace() { |
207 | 0 | return this.namespace; |
208 | |
} |
209 | |
|
210 | |
@Override |
211 | |
public Long getVersionNumber() { |
212 | 0 | return this.versionNumber; |
213 | |
} |
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
@Override |
221 | |
public CategoryDefinition build() { |
222 | 0 | return new CategoryDefinition(this); |
223 | |
} |
224 | |
|
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | 0 | static class Constants { |
231 | |
final static String ROOT_ELEMENT_NAME = "category"; |
232 | |
final static String TYPE_NAME = "CategoryType"; |
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | 0 | public static class Elements { |
240 | |
final static String ID = "id"; |
241 | |
final static String NAME = "name"; |
242 | |
final static String NAMESPACE = "namespace"; |
243 | |
} |
244 | |
} |
245 | |
|
246 | |
|