001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.type; 018 019import java.util.Map; 020 021import org.springframework.util.MultiValueMap; 022 023/** 024 * Defines access to the annotations of a specific type ({@link AnnotationMetadata class} 025 * or {@link MethodMetadata method}), in a form that does not necessarily require the 026 * class-loading. 027 * 028 * @author Juergen Hoeller 029 * @author Mark Fisher 030 * @author Mark Pollack 031 * @author Chris Beams 032 * @author Phillip Webb 033 * @author Sam Brannen 034 * @since 4.0 035 * @see AnnotationMetadata 036 * @see MethodMetadata 037 */ 038public interface AnnotatedTypeMetadata { 039 040 /** 041 * Determine whether the underlying element has an annotation or meta-annotation 042 * of the given type defined. 043 * <p>If this method returns {@code true}, then 044 * {@link #getAnnotationAttributes} will return a non-null Map. 045 * @param annotationName the fully qualified class name of the annotation 046 * type to look for 047 * @return whether a matching annotation is defined 048 */ 049 boolean isAnnotated(String annotationName); 050 051 /** 052 * Retrieve the attributes of the annotation of the given type, if any (i.e. if 053 * defined on the underlying element, as direct annotation or meta-annotation), 054 * also taking attribute overrides on composed annotations into account. 055 * @param annotationName the fully qualified class name of the annotation 056 * type to look for 057 * @return a Map of attributes, with the attribute name as key (e.g. "value") 058 * and the defined attribute value as Map value. This return value will be 059 * {@code null} if no matching annotation is defined. 060 */ 061 Map<String, Object> getAnnotationAttributes(String annotationName); 062 063 /** 064 * Retrieve the attributes of the annotation of the given type, if any (i.e. if 065 * defined on the underlying element, as direct annotation or meta-annotation), 066 * also taking attribute overrides on composed annotations into account. 067 * @param annotationName the fully qualified class name of the annotation 068 * type to look for 069 * @param classValuesAsString whether to convert class references to String 070 * class names for exposure as values in the returned Map, instead of Class 071 * references which might potentially have to be loaded first 072 * @return a Map of attributes, with the attribute name as key (e.g. "value") 073 * and the defined attribute value as Map value. This return value will be 074 * {@code null} if no matching annotation is defined. 075 */ 076 Map<String, Object> getAnnotationAttributes(String annotationName, boolean classValuesAsString); 077 078 /** 079 * Retrieve all attributes of all annotations of the given type, if any (i.e. if 080 * defined on the underlying element, as direct annotation or meta-annotation). 081 * Note that this variant does <i>not</i> take attribute overrides into account. 082 * @param annotationName the fully qualified class name of the annotation 083 * type to look for 084 * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") 085 * and a list of the defined attribute values as Map value. This return value will 086 * be {@code null} if no matching annotation is defined. 087 * @see #getAllAnnotationAttributes(String, boolean) 088 */ 089 MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName); 090 091 /** 092 * Retrieve all attributes of all annotations of the given type, if any (i.e. if 093 * defined on the underlying element, as direct annotation or meta-annotation). 094 * Note that this variant does <i>not</i> take attribute overrides into account. 095 * @param annotationName the fully qualified class name of the annotation 096 * type to look for 097 * @param classValuesAsString whether to convert class references to String 098 * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") 099 * and a list of the defined attribute values as Map value. This return value will 100 * be {@code null} if no matching annotation is defined. 101 * @see #getAllAnnotationAttributes(String) 102 */ 103 MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString); 104 105}