View Javadoc
1   package org.apache.maven.tools.plugin.extractor.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 java.util.HashMap;
23  import java.util.Map;
24  
25  import org.objectweb.asm.AnnotationVisitor;
26  import org.objectweb.asm.Opcodes;
27  
28  /**
29   * Visitor for annotations.
30   *
31   * @author Olivier Lamy
32   * @since 3.0
33   */
34  public class MojoAnnotationVisitor
35      extends AnnotationVisitor
36  {
37      private String annotationClassName;
38  
39      private Map<String, Object> annotationValues = new HashMap<>();
40  
41      MojoAnnotationVisitor( String annotationClassName )
42      {
43          super( Opcodes.ASM9 );
44          this.annotationClassName = annotationClassName;
45      }
46  
47      public Map<String, Object> getAnnotationValues()
48      {
49          return annotationValues;
50      }
51  
52      @Override
53      public void visit( String name, Object value )
54      {
55          annotationValues.put( name, value );
56      }
57  
58      @Override
59      public void visitEnum( String name, String desc, String value )
60      {
61          annotationValues.put( name, value );
62      }
63  
64      @Override
65      public AnnotationVisitor visitAnnotation( String name, String desc )
66      {
67          return new MojoAnnotationVisitor( this.annotationClassName );
68      }
69  
70      @Override
71      public AnnotationVisitor visitArray( String s )
72      {
73          return new MojoAnnotationVisitor( this.annotationClassName );
74      }
75  }