001package org.apache.maven.tools.plugin.extractor.annotations.scanner.visitors; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.HashMap; 023import java.util.Map; 024 025import org.codehaus.plexus.logging.Logger; 026import org.objectweb.asm.AnnotationVisitor; 027import org.objectweb.asm.Opcodes; 028 029/** 030 * @author Olivier Lamy 031 * @since 3.0 032 */ 033public class MojoAnnotationVisitor 034 extends AnnotationVisitor 035{ 036 private Logger logger; 037 038 private String annotationClassName; 039 040 private Map<String, Object> annotationValues = new HashMap<>(); 041 042 MojoAnnotationVisitor( Logger logger, String annotationClassName ) 043 { 044 super( Opcodes.ASM9 ); 045 this.logger = logger; 046 this.annotationClassName = annotationClassName; 047 } 048 049 public Map<String, Object> getAnnotationValues() 050 { 051 return annotationValues; 052 } 053 054 @Override 055 public void visit( String name, Object value ) 056 { 057 annotationValues.put( name, value ); 058 } 059 060 @Override 061 public void visitEnum( String name, String desc, String value ) 062 { 063 annotationValues.put( name, value ); 064 } 065 066 @Override 067 public AnnotationVisitor visitAnnotation( String name, String desc ) 068 { 069 return new MojoAnnotationVisitor( logger, this.annotationClassName ); 070 } 071 072 @Override 073 public AnnotationVisitor visitArray( String s ) 074 { 075 return new MojoAnnotationVisitor( logger, this.annotationClassName ); 076 } 077 078 @Override 079 public void visitEnd() 080 { 081 // no op 082 } 083 084 public String getAnnotationClassName() 085 { 086 return annotationClassName; 087 } 088}