Clover coverage report - Code Coverage for tapestry-annotations release 4.0-beta-1
Coverage timestamp: Fri Jun 24 2005 14:37:32 EDT
file stats: LOC: 71   Methods: 1
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ParameterAnnotationWorker.java 83.3% 95% 100% 92.6%
coverage coverage
 1    // Copyright 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 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    * Generates a {@link org.apache.tapestry.spec.IParameterSpecification} from a
 27    * {@link org.apache.tapestry.annotations.Parameter} annotation and adds it to the
 28    * {@link org.apache.tapestry.spec.IComponentSpecification}.
 29    *
 30    * @author Howard M. Lewis Ship
 31    * @since 4.0
 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    }