Coverage Report - org.apache.maven.tools.plugin.annotations.scanner.visitors.MojoFieldVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
MojoFieldVisitor
77 %
14/18
50 %
1/2
1,25
 
 1  
 package org.apache.maven.tools.plugin.annotations.scanner.visitors;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScanner;
 23  
 import org.codehaus.plexus.logging.Logger;
 24  
 import org.objectweb.asm.AnnotationVisitor;
 25  
 import org.objectweb.asm.Attribute;
 26  
 import org.objectweb.asm.FieldVisitor;
 27  
 import org.objectweb.asm.Type;
 28  
 
 29  
 /**
 30  
  * @author Olivier Lamy
 31  
  * @since 3.0
 32  
  */
 33  
 public class MojoFieldVisitor
 34  
     implements FieldVisitor
 35  
 {
 36  
     private Logger logger;
 37  
 
 38  
     private String fieldName;
 39  
 
 40  
     private MojoAnnotationVisitor mojoAnnotationVisitor;
 41  
 
 42  
     private String className;
 43  
 
 44  
     MojoFieldVisitor( Logger logger, String fieldName, String className )
 45  4
     {
 46  4
         this.logger = logger;
 47  4
         this.fieldName = fieldName;
 48  4
         this.className = className;
 49  4
     }
 50  
 
 51  
     public MojoAnnotationVisitor getMojoAnnotationVisitor()
 52  
     {
 53  16
         return mojoAnnotationVisitor;
 54  
     }
 55  
 
 56  
     public String getFieldName()
 57  
     {
 58  4
         return fieldName;
 59  
     }
 60  
 
 61  
     public AnnotationVisitor visitAnnotation( String desc, boolean visible )
 62  
     {
 63  4
         logger.debug( "MojoFieldVisitor#visitAnnotation:" + desc );
 64  4
         String annotationClassName = Type.getType( desc ).getClassName();
 65  4
         if ( !MojoAnnotationsScanner.FIELD_LEVEL_ANNOTATIONS.contains( annotationClassName ) )
 66  
         {
 67  0
             return null;
 68  
         }
 69  4
         mojoAnnotationVisitor = new MojoAnnotationVisitor( logger, annotationClassName );
 70  4
         return mojoAnnotationVisitor;
 71  
     }
 72  
 
 73  
     public void visitAttribute( Attribute attribute )
 74  
     {
 75  
         // no op
 76  0
     }
 77  
 
 78  
     public void visitEnd()
 79  
     {
 80  
         // no op
 81  4
     }
 82  
 
 83  
     public String getClassName()
 84  
     {
 85  3
         return className;
 86  
     }
 87  
 
 88  
     public void setClassName( String className )
 89  
     {
 90  0
         this.className = className;
 91  0
     }
 92  
 }