1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.component.descriptor; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import org.xwiki.component.util.ObjectUtils; |
27 |
|
|
28 |
|
|
29 |
|
@link |
30 |
|
|
31 |
|
@version |
32 |
|
@param |
33 |
|
@since |
34 |
|
|
|
|
| 58.8% |
Uncovered Elements: 21 (51) |
Complexity: 16 |
Complexity Density: 0.48 |
|
35 |
|
public class DefaultComponentDescriptor<T> extends DefaultComponentRole<T> implements ComponentDescriptor<T> |
36 |
|
{ |
37 |
|
|
38 |
|
@see |
39 |
|
|
40 |
|
private Class< ? extends T> implementation; |
41 |
|
|
42 |
|
|
43 |
|
@see |
44 |
|
|
45 |
|
private ComponentInstantiationStrategy instantiationStrategy = ComponentInstantiationStrategy.SINGLETON; |
46 |
|
|
47 |
|
|
48 |
|
@see |
49 |
|
|
50 |
|
private List<ComponentDependency< ? >> componentDependencies = new ArrayList<ComponentDependency< ? >>(); |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
55 |
3990
|
public DefaultComponentDescriptor()... |
56 |
|
{ |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@link@link |
61 |
|
|
62 |
|
@param |
63 |
|
@since |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
65 |
3913
|
public DefaultComponentDescriptor(ComponentDescriptor<T> descriptor)... |
66 |
|
{ |
67 |
3913
|
super(descriptor); |
68 |
|
|
69 |
3913
|
setImplementation(descriptor.getImplementation()); |
70 |
3913
|
setInstantiationStrategy(descriptor.getInstantiationStrategy()); |
71 |
3913
|
for (ComponentDependency< ? > dependency : descriptor.getComponentDependencies()) { |
72 |
6103
|
addComponentDependency(new DefaultComponentDependency(dependency)); |
73 |
|
} |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
7636
|
public void setImplementation(Class< ? extends T> implementation)... |
80 |
|
{ |
81 |
7636
|
this.implementation = implementation; |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
9502
|
@Override... |
85 |
|
public Class< ? extends T> getImplementation() |
86 |
|
{ |
87 |
9502
|
return implementation; |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
@param |
92 |
|
@see |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
7610
|
public void setInstantiationStrategy(ComponentInstantiationStrategy instantiationStrategy)... |
95 |
|
{ |
96 |
7610
|
this.instantiationStrategy = instantiationStrategy; |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
8173
|
@Override... |
100 |
|
public ComponentInstantiationStrategy getInstantiationStrategy() |
101 |
|
{ |
102 |
8173
|
return this.instantiationStrategy; |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
5808
|
@Override... |
106 |
|
public Collection<ComponentDependency< ? >> getComponentDependencies() |
107 |
|
{ |
108 |
5808
|
return this.componentDependencies; |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
114 |
12270
|
public void addComponentDependency(ComponentDependency< ? > componentDependency)... |
115 |
|
{ |
116 |
12270
|
this.componentDependencies.add(componentDependency); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
@param |
121 |
|
@param |
122 |
|
@param |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
124 |
0
|
public <TT> void addComponentDependency(Class<TT> role, String roleHint)... |
125 |
|
{ |
126 |
0
|
DefaultComponentDependency<TT> componentDependency = new DefaultComponentDependency<TT>(); |
127 |
0
|
componentDependency.setRole(role); |
128 |
0
|
componentDependency.setRoleHint(roleHint); |
129 |
|
|
130 |
0
|
this.componentDependencies.add(componentDependency); |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
133 |
0
|
@Override... |
134 |
|
public String toString() |
135 |
|
{ |
136 |
0
|
StringBuilder buffer = new StringBuilder(super.toString()); |
137 |
0
|
buffer.append(" implementation = [").append(getImplementation() == null ? null : getImplementation().getName()) |
138 |
|
.append("]"); |
139 |
0
|
buffer.append(" instantiation = [").append(getInstantiationStrategy()).append("]"); |
140 |
|
|
141 |
0
|
return buffer.toString(); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
@inheritDoc |
146 |
|
|
147 |
|
@since |
148 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
149 |
83
|
@Override... |
150 |
|
public boolean equals(Object object) |
151 |
|
{ |
152 |
83
|
boolean result; |
153 |
|
|
154 |
|
|
155 |
83
|
if (this == object) { |
156 |
1
|
result = true; |
157 |
|
} else { |
158 |
82
|
if ((object == null) || (object.getClass() != this.getClass())) { |
159 |
0
|
result = false; |
160 |
|
} else { |
161 |
|
|
162 |
82
|
ComponentDescriptor cd = (ComponentDescriptor) object; |
163 |
|
|
164 |
82
|
result = |
165 |
|
super.equals(cd) && ObjectUtils.equals(getImplementation(), cd.getImplementation()) |
166 |
|
&& ObjectUtils.equals(getInstantiationStrategy(), cd.getInstantiationStrategy()) |
167 |
|
&& ObjectUtils.equals(getComponentDependencies(), cd.getComponentDependencies()); |
168 |
|
} |
169 |
|
} |
170 |
|
|
171 |
83
|
return result; |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
@inheritDoc |
176 |
|
|
177 |
|
@since |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
179 |
0
|
@Override... |
180 |
|
public int hashCode() |
181 |
|
{ |
182 |
0
|
int hash = 7; |
183 |
|
|
184 |
0
|
hash = 31 * hash + super.hashCode(); |
185 |
0
|
hash = 31 * hash + ObjectUtils.hasCode(getImplementation()); |
186 |
0
|
hash = 31 * hash + ObjectUtils.hasCode(getInstantiationStrategy()); |
187 |
0
|
hash = 31 * hash + ObjectUtils.hasCode(getComponentDependencies()); |
188 |
|
|
189 |
0
|
return hash; |
190 |
|
} |
191 |
|
} |