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.tapestry.enhance.EnhancementOperation; |
21 |
| import org.apache.tapestry.spec.IComponentSpecification; |
22 |
| import org.apache.tapestry.spec.IParameterSpecification; |
23 |
| import org.apache.tapestry.spec.ParameterSpecification; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class ParameterAnnotationWorker implements MethodAnnotationEnhancementWorker |
34 |
| { |
35 |
| |
36 |
7
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
|
37 |
| Method method) |
38 |
| { |
39 |
7
| Parameter parameter = method.getAnnotation(Parameter.class);
|
40 |
| |
41 |
7
| String propertyName = AnnotationUtils.getPropertyName(method);
|
42 |
| |
43 |
7
| boolean deprecated = method.isAnnotationPresent(Deprecated.class);
|
44 |
| |
45 |
7
| IParameterSpecification ps = new ParameterSpecification();
|
46 |
| |
47 |
7
| String parameterName = parameter.name();
|
48 |
| |
49 |
7
| if (HiveMind.isBlank(parameterName))
|
50 |
6
| parameterName = propertyName;
|
51 |
| |
52 |
7
| Class propertyType = op.getPropertyType(propertyName);
|
53 |
| |
54 |
7
| ps.setAliases(parameter.aliases());
|
55 |
7
| ps.setCache(parameter.cache());
|
56 |
| |
57 |
7
| if (HiveMind.isNonBlank(parameter.defaultBinding()))
|
58 |
1
| ps.setDefaultBindingType(parameter.defaultBinding());
|
59 |
| |
60 |
7
| if (HiveMind.isNonBlank(parameter.defaultValue()))
|
61 |
0
| ps.setDefaultValue(parameter.defaultValue());
|
62 |
| |
63 |
7
| ps.setDeprecated(deprecated);
|
64 |
7
| ps.setParameterName(parameterName);
|
65 |
7
| ps.setPropertyName(propertyName);
|
66 |
7
| ps.setRequired(parameter.required());
|
67 |
7
| ps.setType(propertyType.getName());
|
68 |
| |
69 |
7
| spec.addParameter(ps);
|
70 |
| } |
71 |
| } |