Coverage Report - org.apache.commons.classscan.bcel.BcelField
 
Classes in this File Line Coverage Branch Coverage Complexity
BcelField
93%
15/16
100%
2/2
1.286
 
 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.Field;
 19  
 import org.apache.commons.classscan.model.MetaAnnotation;
 20  
 import org.apache.commons.classscan.model.MetaType;
 21  
 import org.apache.commons.classscan.spi.model.SpiMetaClassLoader;
 22  
 import org.apache.commons.classscan.spi.model.SpiMetaField;
 23  
 
 24  
 public class BcelField implements SpiMetaField {
 25  
 
 26  
     private final String fieldName;
 27  
     private final boolean isStatic;
 28  
     private String fieldSignature;
 29  
     private MetaType metaType;
 30  
     private final AnnotationMap annotations;
 31  
 
 32  908391
     public BcelField(Field field) {
 33  908391
         fieldName = field.getName();
 34  908391
         isStatic = field.isStatic();
 35  908391
         fieldSignature = field.getSignature();
 36  908391
         annotations = AnnotationMap.createAnnotations(field.getAnnotationEntries());
 37  908391
     }
 38  
 
 39  
         @Override
 40  
         public boolean resolve(SpiMetaClassLoader classLoader) {
 41  906642
                 metaType = classLoader.resolveTypeForDescriptor(fieldSignature);
 42  906642
                 if(metaType == null) {
 43  88
                         return false;
 44  
                 }
 45  906554
                 fieldSignature = null;
 46  
                 
 47  906554
                 return annotations.resolve(classLoader);
 48  
         }
 49  
 
 50  
     @Override
 51  
     public String getName() {
 52  33
         return fieldName;
 53  
     }
 54  
 
 55  
     @Override
 56  
     public Set<? extends MetaAnnotation> getAnnotations() {
 57  22
         return annotations;
 58  
     }
 59  
 
 60  
     @Override
 61  
     public MetaAnnotation getAnnotation(String annotationName) {
 62  0
         return annotations.getValue(annotationName);
 63  
     }
 64  
 
 65  
     @Override
 66  
     public boolean isStatic() {
 67  22
         return isStatic;
 68  
     }
 69  
 
 70  
     @Override
 71  
     public MetaType getType() {
 72  22
         return metaType;
 73  
     }
 74  
 }