1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.security.authorization; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.ObjectInputStream; |
24 |
|
import java.io.ObjectOutputStream; |
25 |
|
import java.io.Serializable; |
26 |
|
import java.util.AbstractCollection; |
27 |
|
import java.util.AbstractMap; |
28 |
|
import java.util.AbstractSet; |
29 |
|
import java.util.ArrayList; |
30 |
|
import java.util.Collection; |
31 |
|
import java.util.Iterator; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
import java.util.NoSuchElementException; |
35 |
|
import java.util.Set; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@param |
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 69.1% |
Uncovered Elements: 46 (149) |
Complexity: 49 |
Complexity Density: 0.63 |
|
44 |
|
public class RightMap<V> extends AbstractMap<Right, V> implements Serializable, Cloneable |
45 |
|
{ |
46 |
|
|
47 |
|
private static final long serialVersionUID = 1L; |
48 |
|
|
49 |
|
|
50 |
|
private static final Object NULL = new Object(); |
51 |
|
|
52 |
|
|
53 |
|
private transient List<Object> rights; |
54 |
|
|
55 |
|
|
56 |
|
private transient Set<Right> keySet; |
57 |
|
|
58 |
|
|
59 |
|
private transient Collection<V> values; |
60 |
|
|
61 |
|
|
62 |
|
private transient Set<Entry<Right, V>> entrySet; |
63 |
|
|
64 |
|
|
65 |
|
private transient int size; |
66 |
|
|
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
102 |
public RightMap() {... |
69 |
102 |
rights = new ArrayList<Object>(Right.size()); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@return |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
77 |
1359 |
private Object maskNull(Object value) {... |
78 |
1359 |
return (value == null ? NULL : value); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
@return |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
86 |
2784 |
@SuppressWarnings("unchecked")... |
87 |
|
private V unmaskNull(Object value) { |
88 |
2784 |
return (V) (value == NULL ? null : value); |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
91 |
4 |
@Override... |
92 |
|
public void clear() |
93 |
|
{ |
94 |
4 |
rights.clear(); |
95 |
4 |
size = 0; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
98 |
0 |
@Override... |
99 |
|
@SuppressWarnings("unchecked") |
100 |
|
protected Object clone() throws CloneNotSupportedException |
101 |
|
{ |
102 |
0 |
RightMap<V> clone = (RightMap<V>) super.clone(); |
103 |
0 |
clone.rights.addAll(rights); |
104 |
0 |
clone.size = size(); |
105 |
0 |
return clone; |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
191 |
@Override... |
109 |
|
public boolean containsKey(Object o) |
110 |
|
{ |
111 |
191 |
return o instanceof Right && getValue(((Right) o).ordinal()) != null; |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
114 |
711 |
@Override... |
115 |
|
public boolean containsValue(Object o) |
116 |
|
{ |
117 |
711 |
return rights.contains(maskNull(o)); |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 6 |
Complexity Density: 0.67 |
|
120 |
10 |
@Override... |
121 |
|
public boolean equals(Object o) |
122 |
|
{ |
123 |
10 |
if (!(o instanceof RightMap)) { |
124 |
4 |
return super.equals(o); |
125 |
|
} |
126 |
|
|
127 |
6 |
RightMap rmap = (RightMap) o; |
128 |
|
|
129 |
|
|
130 |
65 |
for (int i = 0; i < Right.size(); i++) { |
131 |
61 |
Object val = getValue(i); |
132 |
61 |
Object rval = rmap.getValue(i); |
133 |
61 |
if (rval != val && (rval == null || !rval.equals(val))) { |
134 |
2 |
return false; |
135 |
|
} |
136 |
|
} |
137 |
4 |
return true; |
138 |
|
} |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
140 |
194 |
@Override... |
141 |
|
public V get(Object o) |
142 |
|
{ |
143 |
194 |
return (o instanceof Right ? unmaskNull(getValue(((Right) o).ordinal())) : null); |
144 |
|
} |
145 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
146 |
12 |
@Override... |
147 |
|
public int hashCode() |
148 |
|
{ |
149 |
12 |
return rights.isEmpty() ? 0 : rights.hashCode(); |
150 |
|
} |
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
53 |
@Override... |
153 |
|
public boolean isEmpty() |
154 |
|
{ |
155 |
53 |
return (size == 0); |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
@param |
161 |
|
@return |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
163 |
11846 |
@SuppressWarnings("unchecked")... |
164 |
|
private V getValue(int index) |
165 |
|
{ |
166 |
11846 |
return (index < rights.size()) ? (V) rights.get(index) : null; |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
@param |
172 |
|
@param |
173 |
|
@return |
174 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 7 |
Complexity Density: 0.5 |
|
175 |
488 |
@SuppressWarnings("unchecked")... |
176 |
|
private V updateValue(int index, Object newValue) |
177 |
|
{ |
178 |
488 |
if (index < 0) { |
179 |
1 |
return null; |
180 |
|
} |
181 |
487 |
if (rights.size() <= index) { |
182 |
91 |
((ArrayList) rights).ensureCapacity(Right.size() + 1); |
183 |
1274 |
while (rights.size() <= Right.size()) { |
184 |
1183 |
rights.add(null); |
185 |
|
} |
186 |
|
} |
187 |
487 |
Object oldValue = rights.set(index, newValue); |
188 |
487 |
if (oldValue == null) { |
189 |
460 |
if (newValue != null) { |
190 |
459 |
size++; |
191 |
|
} |
192 |
460 |
return null; |
193 |
|
} |
194 |
27 |
if (newValue == null) { |
195 |
22 |
size--; |
196 |
|
} |
197 |
27 |
return unmaskNull(oldValue); |
198 |
|
} |
199 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
463 |
@Override... |
201 |
|
public V put(Right right, V value) |
202 |
|
{ |
203 |
463 |
return updateValue(right.ordinal(), maskNull(value)); |
204 |
|
} |
205 |
|
|
|
|
| 33.3% |
Uncovered Elements: 6 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
206 |
2 |
@Override... |
207 |
|
@SuppressWarnings("unchecked") |
208 |
|
public void putAll(Map<? extends Right, ? extends V> map) |
209 |
|
{ |
210 |
2 |
if (map instanceof RightMap) { |
211 |
0 |
RightMap<? extends V> rmap = (RightMap<? extends V>) map; |
212 |
|
|
213 |
0 |
for (int i = 0; i < Right.size(); i++) { |
214 |
0 |
updateValue(i, rmap.getValue(i)); |
215 |
|
} |
216 |
|
} else { |
217 |
2 |
super.putAll(map); |
218 |
|
} |
219 |
|
} |
220 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
221 |
5 |
@Override... |
222 |
|
public V remove(Object o) |
223 |
|
{ |
224 |
5 |
if (o instanceof Right) { |
225 |
5 |
return updateValue(((Right) o).ordinal(), null); |
226 |
|
} |
227 |
0 |
return null; |
228 |
|
} |
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
230 |
653 |
@Override... |
231 |
|
public int size() |
232 |
|
{ |
233 |
653 |
return size; |
234 |
|
} |
235 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
236 |
0 |
@Override... |
237 |
|
public String toString() |
238 |
|
{ |
239 |
0 |
StringBuilder sb = new StringBuilder("["); |
240 |
0 |
boolean first = true; |
241 |
0 |
for (int i = 0; i < rights.size(); i++) { |
242 |
0 |
if (getValue(i) != null) { |
243 |
0 |
if (first) { |
244 |
0 |
first = false; |
245 |
|
} else { |
246 |
0 |
sb.append(", "); |
247 |
|
} |
248 |
0 |
sb.append(Right.get(i).getName()) |
249 |
|
.append(" = ") |
250 |
|
.append(unmaskNull(getValue(i)).toString()); |
251 |
|
} |
252 |
|
} |
253 |
0 |
sb.append("]"); |
254 |
0 |
return sb.toString(); |
255 |
|
} |
256 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
257 |
64 |
@Override... |
258 |
|
public Set<Right> keySet() { |
259 |
64 |
if (keySet == null) { |
260 |
49 |
keySet = new RightSet(); |
261 |
|
} |
262 |
64 |
return keySet; |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 5 |
Complexity Density: 0.71 |
|
268 |
|
private class RightSet extends AbstractSet<Right> |
269 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
270 |
164 |
@Override... |
271 |
|
public Iterator<Right> iterator() { |
272 |
164 |
return new RightIterator(); |
273 |
|
} |
274 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
275 |
206 |
@Override... |
276 |
|
public int size() { |
277 |
206 |
return size; |
278 |
|
} |
279 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
280 |
0 |
@Override... |
281 |
|
public boolean contains(Object o) { |
282 |
0 |
return containsKey(o); |
283 |
|
} |
284 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
285 |
2 |
@Override... |
286 |
|
public boolean remove(Object o) { |
287 |
2 |
int oldSize = size; |
288 |
2 |
RightMap.this.remove(o); |
289 |
2 |
return size != oldSize; |
290 |
|
} |
291 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
292 |
1 |
@Override... |
293 |
|
public void clear() { |
294 |
1 |
RightMap.this.clear(); |
295 |
|
} |
296 |
|
} |
297 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
298 |
112 |
@Override... |
299 |
|
public Collection<V> values() { |
300 |
112 |
if (values == null) { |
301 |
48 |
values = new Values(); |
302 |
|
} |
303 |
112 |
return values; |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 5 |
Complexity Density: 1 |
|
309 |
|
private class Values extends AbstractCollection<V> |
310 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
311 |
367 |
@Override... |
312 |
|
public Iterator<V> iterator() |
313 |
|
{ |
314 |
367 |
return new ValueIterator(); |
315 |
|
} |
316 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
317 |
307 |
@Override... |
318 |
|
public int size() |
319 |
|
{ |
320 |
307 |
return size; |
321 |
|
} |
322 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
323 |
352 |
@Override... |
324 |
|
public boolean contains(Object o) |
325 |
|
{ |
326 |
352 |
return containsValue(o); |
327 |
|
} |
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
329 |
2 |
@Override... |
330 |
|
public boolean remove(Object o) |
331 |
|
{ |
332 |
2 |
return updateValue(rights.indexOf(maskNull(o)), null) != null; |
333 |
|
} |
334 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
335 |
1 |
@Override... |
336 |
|
public void clear() |
337 |
|
{ |
338 |
1 |
RightMap.this.clear(); |
339 |
|
} |
340 |
|
} |
341 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
342 |
115 |
@Override... |
343 |
|
public Set<Entry<Right, V>> entrySet() { |
344 |
115 |
if (entrySet == null) { |
345 |
93 |
entrySet = new EntrySet(); |
346 |
|
} |
347 |
115 |
return entrySet; |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
|
|
| 89.6% |
Uncovered Elements: 5 (48) |
Complexity: 15 |
Complexity Density: 0.58 |
|
353 |
|
private class EntrySet extends AbstractSet<Entry<Right, V>> |
354 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
355 |
269 |
@Override... |
356 |
|
public Iterator<Entry<Right, V>> iterator() |
357 |
|
{ |
358 |
269 |
return new EntryIterator(); |
359 |
|
} |
360 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
361 |
239 |
@Override... |
362 |
|
public boolean contains(Object o) |
363 |
|
{ |
364 |
239 |
if (!(o instanceof Map.Entry)) { |
365 |
51 |
return false; |
366 |
|
} |
367 |
|
|
368 |
188 |
Map.Entry entry = (Map.Entry) o; |
369 |
188 |
return entry.getKey() instanceof Right |
370 |
|
&& maskNull(entry.getValue()).equals(getValue(((Right) entry.getKey()).ordinal())); |
371 |
|
} |
372 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
373 |
5 |
@Override... |
374 |
|
public boolean remove(Object o) |
375 |
|
{ |
376 |
5 |
if (!(o instanceof Map.Entry)) { |
377 |
0 |
return false; |
378 |
|
} |
379 |
|
|
380 |
5 |
Map.Entry entry = (Map.Entry) o; |
381 |
5 |
if (contains(entry)) { |
382 |
2 |
updateValue(((Right) entry.getKey()).ordinal(), null); |
383 |
2 |
return true; |
384 |
|
} |
385 |
3 |
return false; |
386 |
|
} |
387 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
388 |
243 |
@Override... |
389 |
|
public int size() |
390 |
|
{ |
391 |
243 |
return size; |
392 |
|
} |
393 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
394 |
1 |
@Override... |
395 |
|
public void clear() |
396 |
|
{ |
397 |
1 |
RightMap.this.clear(); |
398 |
|
} |
399 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
400 |
51 |
@Override... |
401 |
|
public Object[] toArray() |
402 |
|
{ |
403 |
51 |
return fillArray(new Object[size]); |
404 |
|
} |
405 |
|
|
|
|
| 70% |
Uncovered Elements: 3 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
406 |
51 |
@Override... |
407 |
|
@SuppressWarnings("unchecked") |
408 |
|
public <T> T[] toArray(T[] ts) |
409 |
|
{ |
410 |
51 |
T[] a = ts; |
411 |
51 |
if (a.length < size) { |
412 |
0 |
a = (T[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size); |
413 |
|
} |
414 |
51 |
if (a.length > size) { |
415 |
51 |
a[size] = null; |
416 |
|
} |
417 |
51 |
return (T[]) fillArray(a); |
418 |
|
} |
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
@param |
423 |
|
@return |
424 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
425 |
102 |
private Object[] fillArray(Object[] a)... |
426 |
|
{ |
427 |
102 |
int j = 0; |
428 |
1116 |
for (int i = 0; i < rights.size(); i++) { |
429 |
1014 |
if (getValue(i) != null) { |
430 |
350 |
a[j++] = new AbstractMap.SimpleEntry<Right, V>( |
431 |
|
Right.get(i), unmaskNull(getValue(i))); |
432 |
|
} |
433 |
|
} |
434 |
102 |
return a; |
435 |
|
} |
436 |
|
} |
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
@param |
441 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
442 |
|
private abstract class AbstractRightMapIterator<T> implements Iterator<T> |
443 |
|
{ |
444 |
|
|
445 |
|
protected int index; |
446 |
|
|
447 |
|
|
448 |
|
protected int lastIndex = -1; |
449 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
450 |
4541 |
@Override... |
451 |
|
public boolean hasNext() |
452 |
|
{ |
453 |
|
|
454 |
8203 |
while (index < rights.size() && getValue(index) == null) { |
455 |
3662 |
index++; |
456 |
|
} |
457 |
4541 |
return index != rights.size(); |
458 |
|
} |
459 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
460 |
17 |
@Override... |
461 |
|
public void remove() |
462 |
|
{ |
463 |
17 |
if (lastIndex < 0) { |
464 |
2 |
throw new IllegalStateException(); |
465 |
|
} |
466 |
15 |
updateValue(lastIndex, null); |
467 |
15 |
lastIndex = -1; |
468 |
|
} |
469 |
|
} |
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.5 |
|
474 |
|
private class RightIterator extends AbstractRightMapIterator<Right> |
475 |
|
{ |
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
476 |
365 |
@Override... |
477 |
|
public Right next() |
478 |
|
{ |
479 |
365 |
if (!hasNext()) { |
480 |
0 |
throw new NoSuchElementException(); |
481 |
|
} |
482 |
365 |
lastIndex = index++; |
483 |
365 |
return Right.get(lastIndex); |
484 |
|
} |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.5 |
|
490 |
|
private class ValueIterator extends AbstractRightMapIterator<V> |
491 |
|
{ |
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
492 |
940 |
@Override... |
493 |
|
public V next() |
494 |
|
{ |
495 |
940 |
if (!hasNext()) { |
496 |
0 |
throw new NoSuchElementException(); |
497 |
|
} |
498 |
940 |
lastIndex = index++; |
499 |
940 |
return unmaskNull(getValue(lastIndex)); |
500 |
|
} |
501 |
|
} |
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
|
|
| 53.1% |
Uncovered Elements: 23 (49) |
Complexity: 15 |
Complexity Density: 0.56 |
|
506 |
|
private class EntryIterator extends AbstractRightMapIterator<Entry<Right, V>> implements Map.Entry<Right, V> |
507 |
|
{ |
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
508 |
606 |
@Override... |
509 |
|
public Map.Entry<Right, V> next() |
510 |
|
{ |
511 |
606 |
if (!hasNext()) { |
512 |
0 |
throw new NoSuchElementException(); |
513 |
|
} |
514 |
606 |
lastIndex = index++; |
515 |
606 |
return this; |
516 |
|
} |
517 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
518 |
264 |
@Override... |
519 |
|
public Right getKey() |
520 |
|
{ |
521 |
264 |
checkLastIndex(); |
522 |
264 |
return Right.get(lastIndex); |
523 |
|
} |
524 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
525 |
257 |
@Override... |
526 |
|
public V getValue() |
527 |
|
{ |
528 |
257 |
checkLastIndex(); |
529 |
257 |
return unmaskNull(RightMap.this.getValue(lastIndex)); |
530 |
|
} |
531 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
532 |
2 |
@Override... |
533 |
|
public V setValue(V value) |
534 |
|
{ |
535 |
2 |
checkLastIndex(); |
536 |
2 |
return updateValue(lastIndex, value); |
537 |
|
} |
538 |
|
|
|
|
| 66.7% |
Uncovered Elements: 4 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
539 |
1017 |
@Override... |
540 |
|
public boolean equals(Object o) |
541 |
|
{ |
542 |
1017 |
if (lastIndex < 0) { |
543 |
0 |
return o == this; |
544 |
|
} |
545 |
|
|
546 |
1017 |
if (!(o instanceof Map.Entry)) { |
547 |
0 |
return false; |
548 |
|
} |
549 |
|
|
550 |
1017 |
Map.Entry e = (Map.Entry) o; |
551 |
1017 |
V val = unmaskNull(RightMap.this.getValue(lastIndex)); |
552 |
1017 |
Object rval = e.getValue(); |
553 |
1017 |
return e.getKey() == Right.get(lastIndex) && (val == rval || (val != null && val.equals(rval))); |
554 |
|
} |
555 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
556 |
0 |
@Override... |
557 |
|
public int hashCode() |
558 |
|
{ |
559 |
0 |
if (lastIndex < 0) { |
560 |
0 |
return super.hashCode(); |
561 |
|
} |
562 |
|
|
563 |
0 |
Object value = RightMap.this.getValue(lastIndex); |
564 |
0 |
return Right.get(lastIndex).hashCode() ^ (value == NULL ? 0 : value.hashCode()); |
565 |
|
} |
566 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
567 |
0 |
@Override... |
568 |
|
public String toString() |
569 |
|
{ |
570 |
0 |
if (lastIndex < 0) { |
571 |
0 |
return super.toString(); |
572 |
|
} |
573 |
|
|
574 |
0 |
return Right.get(lastIndex) + "=" + unmaskNull(RightMap.this.getValue(lastIndex)); |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
580 |
523 |
private void checkLastIndex()... |
581 |
|
{ |
582 |
523 |
if (lastIndex < 0) { |
583 |
0 |
throw new IllegalStateException("Entry was removed"); |
584 |
|
} |
585 |
|
} |
586 |
|
} |
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
@param |
592 |
|
@throws |
593 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
594 |
0 |
private void writeObject(ObjectOutputStream s) throws IOException... |
595 |
|
{ |
596 |
|
|
597 |
0 |
s.defaultWriteObject(); |
598 |
|
|
599 |
|
|
600 |
0 |
s.writeInt(size); |
601 |
|
|
602 |
|
|
603 |
0 |
for (Map.Entry<Right, V> e : entrySet()) { |
604 |
0 |
s.writeObject(e.getKey()); |
605 |
0 |
s.writeObject(e.getValue()); |
606 |
|
} |
607 |
|
} |
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
@param |
613 |
|
@throws |
614 |
|
@throws |
615 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
616 |
0 |
@SuppressWarnings("unchecked")... |
617 |
|
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException |
618 |
|
{ |
619 |
|
|
620 |
0 |
s.defaultReadObject(); |
621 |
|
|
622 |
0 |
rights = new ArrayList<Object>(Right.size()); |
623 |
|
|
624 |
|
|
625 |
0 |
for (int i = 0; i < s.readInt(); i++) { |
626 |
0 |
Right key = (Right) s.readObject(); |
627 |
0 |
V value = (V) s.readObject(); |
628 |
0 |
put(key, value); |
629 |
|
} |
630 |
|
} |
631 |
|
} |