1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.blossom.template; |
35 |
|
|
36 |
|
import java.lang.annotation.Annotation; |
37 |
|
import java.lang.reflect.Method; |
38 |
|
import java.util.ArrayList; |
39 |
|
import java.util.HashMap; |
40 |
|
import java.util.List; |
41 |
|
import java.util.Map; |
42 |
|
import javax.jcr.Node; |
43 |
|
|
44 |
|
import org.apache.commons.lang.StringUtils; |
45 |
|
import org.slf4j.Logger; |
46 |
|
import org.slf4j.LoggerFactory; |
47 |
|
import org.springframework.util.ClassUtils; |
48 |
|
import org.springframework.util.ReflectionUtils; |
49 |
|
|
50 |
|
import info.magnolia.cms.core.Content; |
51 |
|
import info.magnolia.cms.security.MgnlUser; |
52 |
|
import info.magnolia.cms.security.User; |
53 |
|
import info.magnolia.cms.util.ContentUtil; |
54 |
|
import info.magnolia.context.Context; |
55 |
|
import info.magnolia.context.MgnlContext; |
56 |
|
import info.magnolia.context.WebContext; |
57 |
|
import info.magnolia.module.blossom.annotation.Area; |
58 |
|
import info.magnolia.module.blossom.annotation.AutoGenerator; |
59 |
|
import info.magnolia.module.blossom.annotation.Available; |
60 |
|
import info.magnolia.module.blossom.annotation.AvailableComponentClasses; |
61 |
|
import info.magnolia.module.blossom.annotation.AvailableComponents; |
62 |
|
import info.magnolia.module.blossom.annotation.ComponentCategory; |
63 |
|
import info.magnolia.module.blossom.annotation.I18nBasename; |
64 |
|
import info.magnolia.module.blossom.annotation.Inherits; |
65 |
|
import info.magnolia.module.blossom.annotation.Template; |
66 |
|
import info.magnolia.module.blossom.annotation.TemplateDescription; |
67 |
|
import info.magnolia.module.blossom.annotation.TernaryBoolean; |
68 |
|
import info.magnolia.module.blossom.dispatcher.BlossomDispatcher; |
69 |
|
import info.magnolia.module.blossom.support.MethodInvocationUtils; |
70 |
|
import info.magnolia.module.blossom.support.ParameterResolver; |
71 |
|
import info.magnolia.rendering.engine.RenderException; |
72 |
|
import info.magnolia.rendering.generator.Generator; |
73 |
|
import info.magnolia.rendering.template.AreaDefinition; |
74 |
|
import info.magnolia.rendering.template.AutoGenerationConfiguration; |
75 |
|
import info.magnolia.rendering.template.ComponentAvailability; |
76 |
|
import info.magnolia.rendering.template.InheritanceConfiguration; |
77 |
|
import info.magnolia.rendering.template.TemplateAvailability; |
78 |
|
import info.magnolia.rendering.template.TemplateDefinition; |
79 |
|
import info.magnolia.rendering.template.configured.ConfiguredComponentAvailability; |
80 |
|
import info.magnolia.rendering.template.configured.ConfiguredInheritance; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@since |
86 |
|
|
|
|
| 73.1% |
Uncovered Elements: 65 (242) |
Complexity: 54 |
Complexity Density: 0.35 |
|
87 |
|
public class TemplateDefinitionBuilder { |
88 |
|
|
89 |
|
private final Logger logger = LoggerFactory.getLogger(getClass()); |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 2 |
Complexity Density: 0.1 |
|
91 |
25 |
public BlossomTemplateDefinition buildTemplateDefinition(BlossomDispatcher dispatcher, DetectedHandlersMetaData detectedHandlers, HandlerMetaData template) {... |
92 |
|
|
93 |
25 |
Class<?> handlerClass = template.getHandlerClass(); |
94 |
25 |
Object handler = template.getHandler(); |
95 |
25 |
String handlerPath = template.getHandlerPath(); |
96 |
25 |
Template annotation = handlerClass.getAnnotation(Template.class); |
97 |
|
|
98 |
25 |
BlossomTemplateDefinition definition = new BlossomTemplateDefinition(); |
99 |
25 |
definition.setId(resolveTemplateId(handlerClass)); |
100 |
24 |
definition.setName(definition.getId()); |
101 |
24 |
definition.setTitle(resolveTemplateTitle(template)); |
102 |
24 |
definition.setDescription(resolveDescription(template)); |
103 |
24 |
definition.setI18nBasename(getI18nBasename(template)); |
104 |
24 |
definition.setHandlerPath(handlerPath); |
105 |
24 |
definition.setDialog(StringUtils.trimToNull(annotation.dialog())); |
106 |
24 |
definition.setVisible(annotation.visible()); |
107 |
24 |
definition.setDispatcher(dispatcher); |
108 |
24 |
definition.setHandler(handler); |
109 |
24 |
TemplateAvailability templateAvailability = resolveTemplateAvailability(template); |
110 |
23 |
if (templateAvailability != null) { |
111 |
6 |
definition.setTemplateAvailability(templateAvailability); |
112 |
|
} |
113 |
23 |
definition.setRenderType("blossom"); |
114 |
|
|
115 |
23 |
definition.setAreas(buildAreaDefinitionsForTemplate(dispatcher, detectedHandlers, template)); |
116 |
|
|
117 |
22 |
return definition; |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
120 |
25 |
protected String resolveTemplateId(Class<?> handlerClass) {... |
121 |
25 |
Template annotation = handlerClass.getAnnotation(Template.class); |
122 |
25 |
if (annotation == null) { |
123 |
1 |
throw new IllegalArgumentException("Could not resolve template id, @Template is not present on class [" + handlerClass.getName() + "]"); |
124 |
|
} |
125 |
24 |
return annotation.id(); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
128 |
24 |
protected String resolveTemplateTitle(HandlerMetaData template) {... |
129 |
24 |
Template annotation = template.getHandlerClass().getAnnotation(Template.class); |
130 |
24 |
return annotation.title(); |
131 |
|
} |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
133 |
24 |
protected String resolveDescription(HandlerMetaData template) {... |
134 |
24 |
TemplateDescription templateDescription = template.getHandlerClass().getAnnotation(TemplateDescription.class); |
135 |
24 |
if (templateDescription != null && StringUtils.isNotEmpty(templateDescription.value())) { |
136 |
5 |
return templateDescription.value(); |
137 |
|
} |
138 |
19 |
return ""; |
139 |
|
} |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
141 |
40 |
protected String getI18nBasename(HandlerMetaData handler) {... |
142 |
40 |
I18nBasename i18nBasename = handler.getHandlerClass().getAnnotation(I18nBasename.class); |
143 |
40 |
return i18nBasename != null ? i18nBasename.value() : null; |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
146 |
39 |
protected Map<String, AreaDefinition> buildAreaDefinitionsForTemplate(BlossomDispatcher dispatcher, DetectedHandlersMetaData detectedHandlers, HandlerMetaData template) {... |
147 |
|
|
148 |
39 |
Map<String, AreaDefinition> areas = new HashMap<String, AreaDefinition>(); |
149 |
|
|
150 |
39 |
Class<?> handlerClass = template.getHandlerClass(); |
151 |
125 |
while (handlerClass != null) { |
152 |
|
|
153 |
87 |
List<HandlerMetaData> list = detectedHandlers.getAreasByEnclosingClass(handlerClass); |
154 |
87 |
if (list != null) { |
155 |
11 |
for (HandlerMetaData area : list) { |
156 |
11 |
BlossomAreaDefinition areaDefinition = buildAreaDefinition(dispatcher, detectedHandlers, area); |
157 |
10 |
areas.put(areaDefinition.getId(), areaDefinition); |
158 |
|
} |
159 |
|
} |
160 |
|
|
161 |
86 |
handlerClass = handlerClass.getSuperclass(); |
162 |
|
} |
163 |
|
|
164 |
38 |
return areas; |
165 |
|
} |
166 |
|
|
|
|
| 86.5% |
Uncovered Elements: 5 (37) |
Complexity: 6 |
Complexity Density: 0.22 |
|
167 |
16 |
protected BlossomAreaDefinition buildAreaDefinition(BlossomDispatcher dispatcher, DetectedHandlersMetaData detectedHandlers, HandlerMetaData area) {... |
168 |
|
|
169 |
16 |
Area annotation = area.getHandlerClass().getAnnotation(Area.class); |
170 |
|
|
171 |
16 |
BlossomAreaDefinition definition = new BlossomAreaDefinition(); |
172 |
16 |
definition.setId(annotation.value()); |
173 |
16 |
definition.setName(annotation.value()); |
174 |
16 |
definition.setTitle(StringUtils.isNotEmpty(annotation.title()) ? annotation.title() : StringUtils.capitalize(annotation.value())); |
175 |
16 |
definition.setRenderType("blossom"); |
176 |
16 |
definition.setHandlerPath(area.getHandlerPath()); |
177 |
16 |
definition.setHandler(area.getHandler()); |
178 |
16 |
definition.setDispatcher(dispatcher); |
179 |
16 |
definition.setDialog(StringUtils.trimToNull(annotation.dialog())); |
180 |
16 |
definition.setI18nBasename(getI18nBasename(area)); |
181 |
16 |
definition.setType(annotation.type().getDefinitionFormat()); |
182 |
16 |
if (annotation.maxComponents() != Integer.MAX_VALUE) { |
183 |
1 |
definition.setMaxComponents(annotation.maxComponents()); |
184 |
|
} |
185 |
16 |
if (annotation.optional() != TernaryBoolean.UNSPECIFIED) { |
186 |
0 |
definition.setOptional(TernaryBoolean.toBoolean(annotation.optional())); |
187 |
|
} |
188 |
16 |
if (annotation.createAreaNode() != TernaryBoolean.UNSPECIFIED) { |
189 |
2 |
Boolean createAreaNode = TernaryBoolean.toBoolean(annotation.createAreaNode()); |
190 |
|
|
191 |
|
|
192 |
2 |
Method method = ReflectionUtils.findMethod(definition.getClass(), "setCreateAreaNode", Boolean.class); |
193 |
2 |
if (method != null) |
194 |
0 |
ReflectionUtils.invokeMethod(method, definition, createAreaNode); |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
16 |
definition.setTemplateScript("<area-script-placeholder>"); |
201 |
|
|
202 |
16 |
definition.setInheritance(resolveInheritanceConfiguration(area)); |
203 |
16 |
definition.setAvailableComponents(resolveAvailableComponents(detectedHandlers, area)); |
204 |
16 |
definition.setAreas(buildAreaDefinitionsForTemplate(dispatcher, detectedHandlers, area)); |
205 |
16 |
definition.setAutoGeneration(resolveAutoGenerationConfiguration(definition, area)); |
206 |
|
|
207 |
15 |
return definition; |
208 |
|
} |
209 |
|
|
|
|
| 61.3% |
Uncovered Elements: 12 (31) |
Complexity: 5 |
Complexity Density: 0.22 |
|
210 |
16 |
protected Map<String, ComponentAvailability> resolveAvailableComponents(DetectedHandlersMetaData detectedHandlers, HandlerMetaData area) {... |
211 |
16 |
Map<String, ComponentAvailability> map = new HashMap<String, ComponentAvailability>(); |
212 |
16 |
AvailableComponents availableComponents = area.getHandlerClass().getAnnotation(AvailableComponents.class); |
213 |
16 |
if (availableComponents != null) { |
214 |
0 |
for (String componentId : availableComponents.value()) { |
215 |
0 |
ConfiguredComponentAvailability availability = new ConfiguredComponentAvailability(); |
216 |
0 |
availability.setId(componentId); |
217 |
0 |
map.put(componentId, availability); |
218 |
|
} |
219 |
|
} |
220 |
16 |
AvailableComponentClasses availableComponentClasses = area.getHandlerClass().getAnnotation(AvailableComponentClasses.class); |
221 |
16 |
if (availableComponentClasses != null) { |
222 |
1 |
for (Class<?> clazz : availableComponentClasses.value()) { |
223 |
1 |
if (clazz.isAnnotation()) { |
224 |
1 |
if (!clazz.isAnnotationPresent(ComponentCategory.class)) { |
225 |
0 |
throw new IllegalArgumentException("Annotation [" + clazz.getName() + "] specified on area [" + area.getHandlerClass().getName() + "] is not a @ComponentCategory"); |
226 |
|
} |
227 |
|
|
228 |
1 |
List<String> templatesInCategory = detectedHandlers.getTemplatesInCategory((Class<? extends Annotation>) clazz); |
229 |
1 |
for (String componentId : templatesInCategory) { |
230 |
1 |
ConfiguredComponentAvailability availability = new ConfiguredComponentAvailability(); |
231 |
1 |
availability.setId(componentId); |
232 |
1 |
map.put(componentId, availability); |
233 |
|
} |
234 |
|
} else { |
235 |
0 |
String componentId = resolveTemplateId(clazz); |
236 |
0 |
ConfiguredComponentAvailability availability = new ConfiguredComponentAvailability(); |
237 |
0 |
availability.setId(componentId); |
238 |
0 |
map.put(componentId, availability); |
239 |
|
} |
240 |
|
} |
241 |
|
} |
242 |
16 |
return map; |
243 |
|
} |
244 |
|
|
|
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
245 |
16 |
protected InheritanceConfiguration resolveInheritanceConfiguration(HandlerMetaData area) {... |
246 |
16 |
Inherits inherits = area.getHandlerClass().getAnnotation(Inherits.class); |
247 |
16 |
ConfiguredInheritance inheritance = new ConfiguredInheritance(); |
248 |
16 |
if (inherits != null) { |
249 |
0 |
inheritance.setEnabled(true); |
250 |
0 |
inheritance.setComponents(inherits.components().getConfigurationFormat()); |
251 |
0 |
inheritance.setProperties(inherits.properties().getConfigurationFormat()); |
252 |
|
} |
253 |
16 |
return inheritance; |
254 |
|
} |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
256 |
24 |
protected TemplateAvailability resolveTemplateAvailability(HandlerMetaData template) {... |
257 |
24 |
Method method = resolveTemplateAvailabilityMethod(template); |
258 |
23 |
if (method != null) { |
259 |
6 |
return new DefaultTemplateAvailability(template.getHandler(), method); |
260 |
|
} |
261 |
17 |
return null; |
262 |
|
} |
263 |
|
|
|
|
| 68.4% |
Uncovered Elements: 6 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
264 |
24 |
protected Method resolveTemplateAvailabilityMethod(HandlerMetaData template) {... |
265 |
|
|
266 |
24 |
final List<Method> matchingMethods = findMethodsAnnotatedWith(template.getHandlerClass(), Available.class); |
267 |
|
|
268 |
24 |
if (matchingMethods.size() == 0) { |
269 |
17 |
return null; |
270 |
|
} |
271 |
7 |
if (matchingMethods.size() != 1) { |
272 |
1 |
throw new IllegalStateException("Multiple @Available annotated methods found for handler [" + template.getHandlerClass() + "]"); |
273 |
|
} |
274 |
6 |
Method method = matchingMethods.get(0); |
275 |
6 |
if (!method.getReturnType().equals(Boolean.TYPE)) { |
276 |
0 |
if (logger.isWarnEnabled()) { |
277 |
0 |
logger.error("Method annotated with @Available has wrong return type [" + method.getClass() + "] should be boolean."); |
278 |
|
} |
279 |
0 |
return null; |
280 |
|
} |
281 |
6 |
return method; |
282 |
|
} |
283 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
284 |
2 |
protected ParameterResolver getTemplateAvailabilityParameters(final Node node, final TemplateDefinition templateDefinition) {... |
285 |
2 |
return new ParameterResolver() { |
286 |
|
|
|
|
| 10.3% |
Uncovered Elements: 26 (29) |
Complexity: 8 |
Complexity Density: 0.53 |
|
287 |
2 |
@Override... |
288 |
|
public Object resolveParameter(Class<?> parameterType) { |
289 |
2 |
if (parameterType.equals(Node.class)) { |
290 |
2 |
return node; |
291 |
|
} |
292 |
0 |
if (parameterType.equals(Content.class)) { |
293 |
0 |
return ContentUtil.asContent(node); |
294 |
|
} |
295 |
0 |
if (parameterType.equals(TemplateDefinition.class)) { |
296 |
0 |
return templateDefinition; |
297 |
|
} |
298 |
0 |
if (parameterType.isAssignableFrom(WebContext.class)) { |
299 |
0 |
return MgnlContext.getWebContext(); |
300 |
|
} |
301 |
0 |
if (parameterType.isAssignableFrom(Context.class)) { |
302 |
0 |
return MgnlContext.getInstance(); |
303 |
|
} |
304 |
0 |
if (parameterType.isAssignableFrom(User.class)) { |
305 |
0 |
return MgnlContext.getUser(); |
306 |
|
} |
307 |
0 |
if (parameterType.isAssignableFrom(MgnlUser.class)) { |
308 |
0 |
return MgnlContext.getUser(); |
309 |
|
} |
310 |
0 |
return super.resolveParameter(parameterType); |
311 |
|
} |
312 |
|
}; |
313 |
|
} |
314 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
315 |
|
private class DefaultTemplateAvailability implements TemplateAvailability { |
316 |
|
|
317 |
|
private final Object handler; |
318 |
|
private final Method method; |
319 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
320 |
6 |
public DefaultTemplateAvailability(Object handler, Method method) {... |
321 |
6 |
this.handler = handler; |
322 |
6 |
this.method = method; |
323 |
|
} |
324 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
325 |
2 |
@Override... |
326 |
|
public boolean isAvailable(Node node, TemplateDefinition templateDefinition) { |
327 |
2 |
ParameterResolver parameters = getTemplateAvailabilityParameters(node, templateDefinition); |
328 |
2 |
return (Boolean) MethodInvocationUtils.invoke(method, handler, parameters); |
329 |
|
} |
330 |
|
} |
331 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
332 |
16 |
private AutoGenerationConfiguration resolveAutoGenerationConfiguration(BlossomAreaDefinition definition, HandlerMetaData template) {... |
333 |
16 |
final List<Method> matchingMethods = findMethodsAnnotatedWith(template.getHandlerClass(), AutoGenerator.class); |
334 |
|
|
335 |
16 |
if (matchingMethods.size() == 0) { |
336 |
11 |
return null; |
337 |
|
} |
338 |
5 |
if (matchingMethods.size() != 1) { |
339 |
1 |
throw new IllegalStateException("Multiple @AutoGenerator annotated methods found for handler [" + template.getHandlerClass() + "]"); |
340 |
|
} |
341 |
4 |
return new BlossomAutoGenerationConfiguration(this, definition, template.getHandler(), matchingMethods.get(0)); |
342 |
|
} |
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
@see |
348 |
|
@see |
349 |
|
@since |
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.25 |
|
351 |
|
public static class BlossomAutoGenerationConfiguration implements AutoGenerationConfiguration { |
352 |
|
|
353 |
|
private TemplateDefinitionBuilder templateDefinitionBuilder; |
354 |
|
private final BlossomAreaDefinition definition; |
355 |
|
private final Object handler; |
356 |
|
private final Method method; |
357 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
358 |
4 |
public BlossomAutoGenerationConfiguration(TemplateDefinitionBuilder templateDefinitionBuilder, BlossomAreaDefinition definition, Object handler, Method method) {... |
359 |
4 |
this.templateDefinitionBuilder = templateDefinitionBuilder; |
360 |
4 |
this.definition = definition; |
361 |
4 |
this.handler = handler; |
362 |
4 |
this.method = method; |
363 |
|
} |
364 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
365 |
|
public TemplateDefinitionBuilder getTemplateDefinitionBuilder() {... |
366 |
|
return templateDefinitionBuilder; |
367 |
|
} |
368 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
369 |
|
public Object getHandler() {... |
370 |
|
return handler; |
371 |
|
} |
372 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
373 |
|
public Method getMethod() {... |
374 |
|
return method; |
375 |
|
} |
376 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
377 |
|
public BlossomAreaDefinition getDefinition() {... |
378 |
|
return definition; |
379 |
|
} |
380 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
381 |
|
@Override... |
382 |
|
public Map<String, Object> getContent() { |
383 |
|
return null; |
384 |
|
} |
385 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
386 |
|
@Override... |
387 |
|
public Class getGeneratorClass() { |
388 |
|
return (Class) BlossomGenerator.class; |
389 |
|
} |
390 |
|
} |
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
@see |
396 |
|
@see |
397 |
|
@since |
398 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
399 |
|
public static class BlossomGenerator implements Generator<BlossomAutoGenerationConfiguration> { |
400 |
|
|
401 |
|
private final Node node; |
402 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
403 |
0 |
public BlossomGenerator(Node node) {... |
404 |
0 |
this.node = node; |
405 |
|
} |
406 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
407 |
|
public Node getNode() {... |
408 |
|
return node; |
409 |
|
} |
410 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
411 |
0 |
@Override... |
412 |
|
public void generate(final BlossomAutoGenerationConfiguration configuration) throws RenderException { |
413 |
0 |
ParameterResolver parameters = configuration.getTemplateDefinitionBuilder().getAutoGenerationParameters(configuration, node); |
414 |
0 |
MethodInvocationUtils.invoke(configuration.getMethod(), configuration.getHandler(), parameters); |
415 |
|
} |
416 |
|
} |
417 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
418 |
0 |
protected ParameterResolver getAutoGenerationParameters(final BlossomAutoGenerationConfiguration configuration, final Node node) {... |
419 |
0 |
return new ParameterResolver() { |
420 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
421 |
0 |
@Override... |
422 |
|
public Object resolveParameter(Class<?> parameterType) { |
423 |
0 |
if (parameterType.equals(Node.class)) { |
424 |
0 |
return node; |
425 |
|
} |
426 |
0 |
if (parameterType.isAssignableFrom(BlossomAreaDefinition.class)) { |
427 |
0 |
return configuration.getDefinition(); |
428 |
|
} |
429 |
0 |
return super.resolveParameter(parameterType); |
430 |
|
} |
431 |
|
}; |
432 |
|
} |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
@param |
440 |
|
@param |
441 |
|
@return |
442 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
443 |
40 |
private static List<Method> findMethodsAnnotatedWith(Class<?> clazz, Class<? extends Annotation> annotationClass) {... |
444 |
40 |
List<Method> matchingMethods = new ArrayList<Method>(); |
445 |
40 |
Class<?> currentClass = clazz; |
446 |
114 |
while (matchingMethods.isEmpty() && currentClass != null) { |
447 |
74 |
Method[] methods = currentClass.getDeclaredMethods(); |
448 |
74 |
for (final Method method : methods) { |
449 |
|
|
450 |
|
|
451 |
384 |
if (!method.isAnnotationPresent(annotationClass)) { |
452 |
368 |
continue; |
453 |
|
} |
454 |
|
|
455 |
|
|
456 |
16 |
if (!method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) { |
457 |
2 |
continue; |
458 |
|
} |
459 |
|
|
460 |
14 |
matchingMethods.add(method); |
461 |
|
} |
462 |
74 |
currentClass = currentClass.getSuperclass(); |
463 |
|
} |
464 |
40 |
return matchingMethods; |
465 |
|
} |
466 |
|
} |