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.Set; 020 021/** 022 * Interface that defines abstract access to the annotations of a specific 023 * class, in a form that does not require that class to be loaded yet. 024 * 025 * @author Juergen Hoeller 026 * @author Mark Fisher 027 * @author Phillip Webb 028 * @author Sam Brannen 029 * @since 2.5 030 * @see StandardAnnotationMetadata 031 * @see org.springframework.core.type.classreading.MetadataReader#getAnnotationMetadata() 032 * @see AnnotatedTypeMetadata 033 */ 034public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata { 035 036 /** 037 * Get the fully qualified class names of all annotation types that 038 * are <em>present</em> on the underlying class. 039 * @return the annotation type names 040 */ 041 Set<String> getAnnotationTypes(); 042 043 /** 044 * Get the fully qualified class names of all meta-annotation types that 045 * are <em>present</em> on the given annotation type on the underlying class. 046 * @param annotationName the fully qualified class name of the meta-annotation 047 * type to look for 048 * @return the meta-annotation type names 049 */ 050 Set<String> getMetaAnnotationTypes(String annotationName); 051 052 /** 053 * Determine whether an annotation of the given type is <em>present</em> on 054 * the underlying class. 055 * @param annotationName the fully qualified class name of the annotation 056 * type to look for 057 * @return {@code true} if a matching annotation is present 058 */ 059 boolean hasAnnotation(String annotationName); 060 061 /** 062 * Determine whether the underlying class has an annotation that is itself 063 * annotated with the meta-annotation of the given type. 064 * @param metaAnnotationName the fully qualified class name of the 065 * meta-annotation type to look for 066 * @return {@code true} if a matching meta-annotation is present 067 */ 068 boolean hasMetaAnnotation(String metaAnnotationName); 069 070 /** 071 * Determine whether the underlying class has any methods that are 072 * annotated (or meta-annotated) with the given annotation type. 073 * @param annotationName the fully qualified class name of the annotation 074 * type to look for 075 */ 076 boolean hasAnnotatedMethods(String annotationName); 077 078 /** 079 * Retrieve the method metadata for all methods that are annotated 080 * (or meta-annotated) with the given annotation type. 081 * <p>For any returned method, {@link MethodMetadata#isAnnotated} will 082 * return {@code true} for the given annotation type. 083 * @param annotationName the fully qualified class name of the annotation 084 * type to look for 085 * @return a set of {@link MethodMetadata} for methods that have a matching 086 * annotation. The return value will be an empty set if no methods match 087 * the annotation type. 088 */ 089 Set<MethodMetadata> getAnnotatedMethods(String annotationName); 090 091}