1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.annotations; |
16 |
| |
17 |
| import java.lang.reflect.Method; |
18 |
| |
19 |
| import org.apache.hivemind.HiveMind; |
20 |
| import org.apache.hivemind.Location; |
21 |
| import org.apache.tapestry.enhance.EnhancementOperation; |
22 |
| import org.apache.tapestry.spec.IComponentSpecification; |
23 |
| import org.apache.tapestry.spec.IParameterSpecification; |
24 |
| import org.apache.tapestry.spec.ParameterSpecification; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| public class ParameterAnnotationWorker implements MethodAnnotationEnhancementWorker |
35 |
| { |
36 |
| |
37 |
14
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
|
38 |
| Method method, Location location) |
39 |
| { |
40 |
14
| Parameter parameter = method.getAnnotation(Parameter.class);
|
41 |
| |
42 |
14
| String propertyName = AnnotationUtils.getPropertyName(method);
|
43 |
| |
44 |
14
| boolean deprecated = method.isAnnotationPresent(Deprecated.class);
|
45 |
| |
46 |
14
| IParameterSpecification ps = new ParameterSpecification();
|
47 |
| |
48 |
14
| String parameterName = parameter.name();
|
49 |
| |
50 |
14
| if (HiveMind.isBlank(parameterName))
|
51 |
12
| parameterName = propertyName;
|
52 |
| |
53 |
14
| Class propertyType = op.getPropertyType(propertyName);
|
54 |
| |
55 |
14
| ps.setAliases(parameter.aliases());
|
56 |
14
| ps.setCache(parameter.cache());
|
57 |
| |
58 |
14
| if (HiveMind.isNonBlank(parameter.defaultValue()))
|
59 |
2
| ps.setDefaultValue(parameter.defaultValue());
|
60 |
| |
61 |
14
| ps.setDeprecated(deprecated);
|
62 |
14
| ps.setParameterName(parameterName);
|
63 |
14
| ps.setPropertyName(propertyName);
|
64 |
14
| ps.setRequired(parameter.required());
|
65 |
14
| ps.setType(propertyType.getName());
|
66 |
14
| ps.setLocation(location);
|
67 |
| |
68 |
14
| spec.addParameter(ps);
|
69 |
| } |
70 |
| } |