Coverage Report - org.apache.commons.classscan.bcel.BcelParameter
 
Classes in this File Line Coverage Branch Coverage Complexity
BcelParameter
92%
13/14
100%
4/4
1.6
 
 1  
 /*
 2  
  * Licensed under the Apache License, Version 2.0 (the "License");
 3  
  * you may not use this file except in compliance with the License.
 4  
  * You may obtain a copy of the License at
 5  
  *
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  *
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package org.apache.commons.classscan.bcel;
 15  
 
 16  
 import java.util.Set;
 17  
 
 18  
 import org.apache.bcel.classfile.ParameterAnnotationEntry;
 19  
 import org.apache.bcel.generic.Type;
 20  
 import org.apache.commons.classscan.model.MetaAnnotation;
 21  
 import org.apache.commons.classscan.model.MetaType;
 22  
 import org.apache.commons.classscan.spi.model.SpiMetaAnnotation;
 23  
 import org.apache.commons.classscan.spi.model.SpiMetaClassLoader;
 24  
 import org.apache.commons.classscan.spi.model.SpiMetaParameter;
 25  
 import org.apache.commons.classscan.util.NameSet;
 26  
 import org.slf4j.Logger;
 27  
 import org.slf4j.LoggerFactory;
 28  
 
 29  
 public class BcelParameter implements SpiMetaParameter {
 30  
 
 31  11
     private static final Logger logger = LoggerFactory.getLogger(BcelParameter.class);
 32  
 
 33  
     private MetaType type;
 34  
     private String typeName;
 35  
     private final NameSet<? extends SpiMetaAnnotation> annotations;
 36  
 
 37  2098866
     public BcelParameter(Type argType, ParameterAnnotationEntry annotationEntry) {
 38  2098866
             typeName = argType.getSignature();
 39  2098866
         annotations = AnnotationMap.createAnnotations(annotationEntry != null 
 40  
                         ?annotationEntry.getAnnotationEntries() :null);
 41  2098866
     }
 42  
 
 43  
         @Override
 44  
         public boolean resolve(SpiMetaClassLoader classLoader) {
 45  2095918
         type = classLoader.resolveTypeForDescriptor(typeName);
 46  2095918
         if(type==null) {
 47  66
                 logger.info("cannot resolve "+typeName+" as a parameter type");
 48  66
                 return false;
 49  
         }
 50  2095852
         typeName= null;
 51  2095852
                 return annotations.resolve(classLoader);
 52  
         }
 53  
 
 54  
     @Override
 55  
     public Set<? extends MetaAnnotation> getAnnotations() {
 56  11
         return annotations;
 57  
     }
 58  
 
 59  
     @Override
 60  
     public MetaAnnotation getAnnotation(String annotationName) {
 61  0
         return annotations.getValue(annotationName);
 62  
     }
 63  
 
 64  
     @Override
 65  
     public MetaType getType() {
 66  11
         return type;
 67  
     }
 68  
 }