1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.configuration.internal; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Map; |
25 |
|
import java.util.concurrent.ConcurrentHashMap; |
26 |
|
|
27 |
|
import javax.inject.Named; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Singleton |
42 |
|
@Named("memory") |
|
|
| 64.3% |
Uncovered Elements: 10 (28) |
Complexity: 10 |
Complexity Density: 0.62 |
|
43 |
|
public class MemoryConfigurationSource extends AbstractConfigurationSource |
44 |
|
{ |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
private Map<String, Object> properties = new ConcurrentHashMap<String, Object>(); |
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
@param |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
1
|
public void setProperty(String key, Object value)... |
55 |
|
{ |
56 |
1
|
this.properties.put(key, value); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@param |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0
|
public void removeProperty(String key)... |
63 |
|
{ |
64 |
0
|
this.properties.remove(key); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
67 |
70
|
@Override... |
68 |
|
public <T> T getProperty(String key, T defaultValue) |
69 |
|
{ |
70 |
70
|
T value; |
71 |
|
|
72 |
70
|
if (this.properties.containsKey(key)) { |
73 |
1
|
value = (T) this.properties.get(key); |
74 |
|
} else { |
75 |
69
|
value = defaultValue; |
76 |
|
} |
77 |
|
|
78 |
70
|
return value; |
79 |
|
} |
80 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
81 |
33
|
@Override... |
82 |
|
public <T> T getProperty(String key, Class<T> valueClass) |
83 |
|
{ |
84 |
33
|
T value; |
85 |
|
|
86 |
33
|
if (this.properties.containsKey(key)) { |
87 |
0
|
value = (T) this.properties.get(key); |
88 |
|
} else { |
89 |
33
|
value = getDefault(valueClass); |
90 |
|
} |
91 |
|
|
92 |
33
|
return value; |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
75
|
@Override... |
96 |
|
public <T> T getProperty(String key) |
97 |
|
{ |
98 |
75
|
return (T) this.properties.get(key); |
99 |
|
} |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
0
|
@Override... |
102 |
|
public List<String> getKeys() |
103 |
|
{ |
104 |
0
|
return new ArrayList<String>(this.properties.keySet()); |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0
|
@Override... |
108 |
|
public boolean containsKey(String key) |
109 |
|
{ |
110 |
0
|
return this.properties.containsKey(key); |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0
|
@Override... |
114 |
|
public boolean isEmpty() |
115 |
|
{ |
116 |
0
|
return this.properties.isEmpty(); |
117 |
|
} |
118 |
|
} |