1 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 34 public class ParameterAnnotationWorker implements MethodAnnotationEnhancementWorker 35 { 36 37 public void performEnhancement(EnhancementOperation op, IComponentSpecification spec, 38 Method method, Location location) 39 { 40 Parameter parameter = method.getAnnotation(Parameter.class); 41 42 String propertyName = AnnotationUtils.getPropertyName(method); 43 44 boolean deprecated = method.isAnnotationPresent(Deprecated .class); 45 46 IParameterSpecification ps = new ParameterSpecification(); 47 48 String parameterName = parameter.name(); 49 50 if (HiveMind.isBlank(parameterName)) 51 parameterName = propertyName; 52 53 Class propertyType = op.getPropertyType(propertyName); 54 55 ps.setAliases(parameter.aliases()); 56 ps.setCache(parameter.cache()); 57 58 if (HiveMind.isNonBlank(parameter.defaultBinding())) 59 ps.setDefaultBindingType(parameter.defaultBinding()); 60 61 if (HiveMind.isNonBlank(parameter.defaultValue())) 62 ps.setDefaultValue(parameter.defaultValue()); 63 64 ps.setDeprecated(deprecated); 65 ps.setParameterName(parameterName); 66 ps.setPropertyName(propertyName); 67 ps.setRequired(parameter.required()); 68 ps.setType(propertyType.getName()); 69 ps.setLocation(location); 70 71 spec.addParameter(ps); 72 } 73 } 74 | Popular Tags |