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