Clover coverage report - Code Coverage for tapestry-annotations release 4.0.2
Coverage timestamp: Thu Apr 13 2006 10:55:35 EDT
file stats: LOC: 70   Methods: 1
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ParameterAnnotationWorker.java 100% 100% 100% 100%
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.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    * Generates a {@link org.apache.tapestry.spec.IParameterSpecification} from a
 28    * {@link org.apache.tapestry.annotations.Parameter} annotation and adds it to the
 29    * {@link org.apache.tapestry.spec.IComponentSpecification}.
 30    *
 31    * @author Howard M. Lewis Ship
 32    * @since 4.0
 33    */
 34    public class ParameterAnnotationWorker implements MethodAnnotationEnhancementWorker
 35    {
 36   
 37  7 public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
 38    Method method, Location location)
 39    {
 40  7 Parameter parameter = method.getAnnotation(Parameter.class);
 41   
 42  7 String propertyName = AnnotationUtils.getPropertyName(method);
 43   
 44  7 boolean deprecated = method.isAnnotationPresent(Deprecated.class);
 45   
 46  7 IParameterSpecification ps = new ParameterSpecification();
 47   
 48  7 String parameterName = parameter.name();
 49   
 50  7 if (HiveMind.isBlank(parameterName))
 51  6 parameterName = propertyName;
 52   
 53  7 Class propertyType = op.getPropertyType(propertyName);
 54   
 55  7 ps.setAliases(parameter.aliases());
 56  7 ps.setCache(parameter.cache());
 57   
 58  7 if (HiveMind.isNonBlank(parameter.defaultValue()))
 59  1 ps.setDefaultValue(parameter.defaultValue());
 60   
 61  7 ps.setDeprecated(deprecated);
 62  7 ps.setParameterName(parameterName);
 63  7 ps.setPropertyName(propertyName);
 64  7 ps.setRequired(parameter.required());
 65  7 ps.setType(propertyType.getName());
 66  7 ps.setLocation(location);
 67   
 68  7 spec.addParameter(ps);
 69    }
 70    }