1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.script.internal.safe; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.HashSet; |
25 |
|
import java.util.LinkedHashSet; |
26 |
|
import java.util.Set; |
27 |
|
|
28 |
|
import javax.inject.Inject; |
29 |
|
import javax.inject.Singleton; |
30 |
|
|
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
39 |
|
@Component |
40 |
|
@Singleton |
41 |
|
@SuppressWarnings("rawtypes") |
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.33 |
|
42 |
|
public class CollectionScriptSafeProvider implements ScriptSafeProvider<Collection> |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@Inject |
48 |
|
private ScriptSafeProvider safeProvider; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
50 |
100 |
@Override... |
51 |
|
public <S> S get(Collection unsafe) |
52 |
|
{ |
53 |
100 |
Collection safe; |
54 |
|
|
55 |
100 |
if (unsafe instanceof Set) { |
56 |
49 |
if (unsafe instanceof LinkedHashSet) { |
57 |
1 |
safe = new LinkedHashSet(unsafe.size()); |
58 |
|
} else { |
59 |
48 |
safe = new HashSet(unsafe.size()); |
60 |
|
} |
61 |
|
} else { |
62 |
51 |
safe = new ArrayList(unsafe.size()); |
63 |
|
} |
64 |
|
|
65 |
100 |
for (Object unsafeElement : unsafe) { |
66 |
5282 |
safe.add(this.safeProvider.get(unsafeElement)); |
67 |
|
} |
68 |
|
|
69 |
100 |
return (S) safe; |
70 |
|
} |
71 |
|
} |