1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.se.dto.list; |
17 |
|
|
18 |
|
import java.util.Arrays; |
19 |
|
import java.util.HashSet; |
20 |
|
import java.util.Iterator; |
21 |
|
import java.util.Set; |
22 |
|
|
23 |
|
import org.qedeq.kernel.se.base.list.Element; |
24 |
|
import org.qedeq.kernel.se.base.list.ElementList; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@link |
29 |
|
|
30 |
|
@author |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (122) |
Complexity: 36 |
Complexity Density: 0.52 |
|
32 |
|
public class ElementSet { |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
private final Set elements; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
52
|
public ElementSet() {... |
43 |
52
|
this.elements = new HashSet(); |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
@throws |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
53 |
40
|
public ElementSet(final Element[] elements) {... |
54 |
40
|
if (elements == null) { |
55 |
1
|
throw new IllegalArgumentException( |
56 |
|
"NullPointer as element array is not allowed"); |
57 |
|
} |
58 |
39
|
this.elements = new HashSet(Arrays.asList(elements)); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
@param |
66 |
|
@throws |
67 |
|
|
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
69 |
16
|
public ElementSet(final ElementSet set) {... |
70 |
16
|
if (set == null) { |
71 |
1
|
throw new IllegalArgumentException( |
72 |
|
"NullPointer as set is not allowed"); |
73 |
|
} |
74 |
15
|
this.elements = new HashSet(set.elements); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
@param |
83 |
|
|
84 |
|
@throws |
85 |
|
|
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
87 |
3
|
public ElementSet(final ElementList element) {... |
88 |
3
|
if (element == null) { |
89 |
1
|
throw new IllegalArgumentException( |
90 |
|
"NullPointer as element is not allowed"); |
91 |
|
} |
92 |
2
|
if (element.isAtom()) { |
93 |
1
|
throw new IllegalArgumentException( |
94 |
|
"text as element is not allowed"); |
95 |
|
} |
96 |
1
|
this.elements = new HashSet(element.getElements()); |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
@param |
104 |
|
@return |
105 |
|
@throws |
106 |
|
|
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
108 |
13
|
public final boolean contains(final Element element) {... |
109 |
13
|
if (element == null) { |
110 |
1
|
throw new IllegalArgumentException("NullPointer as element is not allowed"); |
111 |
|
} |
112 |
12
|
return this.elements.contains(element); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@return |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
4
|
public final boolean isEmpty() {... |
121 |
4
|
return elements.isEmpty(); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
@return |
130 |
|
@throws |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
132 |
6
|
public final boolean isSubset(final ElementSet set) {... |
133 |
6
|
if (set == null) { |
134 |
1
|
throw new IllegalArgumentException("NullPointer as set is not allowed"); |
135 |
|
} |
136 |
5
|
return set.elements.containsAll(this.elements); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
@param |
145 |
|
@return |
146 |
|
@throws |
147 |
|
|
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
149 |
56
|
public final ElementSet add(final Element element) {... |
150 |
56
|
if (element == null) { |
151 |
1
|
throw new IllegalArgumentException("NullPointer as element is not allowed"); |
152 |
|
} |
153 |
55
|
elements.add(element); |
154 |
55
|
return this; |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
@link |
160 |
|
|
161 |
|
|
162 |
|
@param |
163 |
|
@return |
164 |
|
@throws |
165 |
|
|
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
167 |
6
|
public final ElementSet union(final ElementSet set) {... |
168 |
6
|
if (set == null) { |
169 |
1
|
throw new IllegalArgumentException( |
170 |
|
"NullPointer as set is not allowed"); |
171 |
|
} |
172 |
5
|
elements.addAll(set.elements); |
173 |
5
|
return this; |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
@param |
181 |
|
@return |
182 |
|
@throws |
183 |
|
|
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
185 |
6
|
public final ElementSet remove(final Element element) {... |
186 |
6
|
if (element == null) { |
187 |
1
|
throw new IllegalArgumentException( |
188 |
|
"NullPointer as element is not allowed"); |
189 |
|
} |
190 |
5
|
elements.remove(element); |
191 |
5
|
return this; |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
@link |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
@param |
201 |
|
|
202 |
|
@return |
203 |
|
@throws |
204 |
|
|
205 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
206 |
10
|
public final ElementSet minus(final ElementSet set) {... |
207 |
10
|
if (set == null) { |
208 |
1
|
throw new IllegalArgumentException( |
209 |
|
"NullPointer as set is not allowed"); |
210 |
|
} |
211 |
9
|
this.elements.removeAll(set.elements); |
212 |
9
|
return this; |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
@param |
220 |
|
@return |
221 |
|
@throws |
222 |
|
|
223 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
224 |
6
|
public final ElementSet intersection(final ElementSet set) {... |
225 |
6
|
if (set == null) { |
226 |
1
|
throw new IllegalArgumentException( |
227 |
|
"NullPointer as set is not allowed"); |
228 |
|
} |
229 |
5
|
this.elements.retainAll(set.elements); |
230 |
5
|
return this; |
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
@param |
238 |
|
@return |
239 |
|
|
240 |
|
@throws |
241 |
|
|
242 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
243 |
7
|
public final ElementSet newIntersection(final ElementSet set) {... |
244 |
7
|
if (set == null) { |
245 |
1
|
throw new IllegalArgumentException( |
246 |
|
"NullPointer as set is not allowed"); |
247 |
|
} |
248 |
6
|
final ElementSet result = new ElementSet(this); |
249 |
6
|
result.elements.retainAll(set.elements); |
250 |
6
|
return result; |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
@param |
260 |
|
|
261 |
|
@return |
262 |
|
@throws |
263 |
|
|
264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
265 |
5
|
public final ElementSet newDelta(final ElementSet set) {... |
266 |
5
|
if (set == null) { |
267 |
1
|
throw new IllegalArgumentException( |
268 |
|
"NullPointer as set is not allowed"); |
269 |
|
} |
270 |
4
|
final ElementSet union = new ElementSet(this); |
271 |
4
|
union.union(set); |
272 |
4
|
final ElementSet intersection = new ElementSet(this); |
273 |
4
|
intersection.intersection(set); |
274 |
4
|
union.minus(intersection); |
275 |
4
|
return union; |
276 |
|
} |
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
@return |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
283 |
11
|
public final int size() {... |
284 |
11
|
return this.elements.size(); |
285 |
|
} |
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
@return |
293 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
294 |
2
|
public Iterator iterator() {... |
295 |
2
|
return this.elements.iterator(); |
296 |
|
} |
297 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
298 |
45
|
public final boolean equals(final Object obj) {... |
299 |
45
|
if (obj == null) { |
300 |
4
|
return false; |
301 |
|
} |
302 |
41
|
if (obj.getClass() == ElementSet.class) { |
303 |
40
|
return this.elements.equals(((ElementSet) obj).elements); |
304 |
|
} |
305 |
1
|
return false; |
306 |
|
} |
307 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
308 |
8
|
public final int hashCode() {... |
309 |
8
|
return elements.hashCode(); |
310 |
|
} |
311 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
312 |
7
|
public final String toString() {... |
313 |
7
|
final StringBuffer result = new StringBuffer(); |
314 |
7
|
result.append("{"); |
315 |
7
|
final Iterator iterator = elements.iterator(); |
316 |
15
|
while (iterator.hasNext()) { |
317 |
8
|
result.append(iterator.next()); |
318 |
8
|
if (iterator.hasNext()) { |
319 |
2
|
result.append(", "); |
320 |
|
} |
321 |
|
} |
322 |
7
|
result.append("}"); |
323 |
7
|
return result.toString(); |
324 |
|
} |
325 |
|
|
326 |
|
} |