Class AnnotationTypeFilter
- java.lang.Object
- org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
- org.springframework.core.type.filter.AnnotationTypeFilter
- All Implemented Interfaces:
TypeFilter
public class AnnotationTypeFilter extends AbstractTypeHierarchyTraversingFilter
A simple filter which matches classes with a given annotation, checking inherited annotations as well.The matching logic mirrors that of
Class.isAnnotationPresent(Class)
.- Since:
- 2.5
- Author:
- Mark Fisher, Ramnivas Laddad, Juergen Hoeller
Field Summary
Fields inherited from class org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
logger
Constructor Summary
Constructors Constructor Description AnnotationTypeFilter(Class<? extends Annotation> annotationType)
Create a new AnnotationTypeFilter for the given annotation type.AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations)
Create a new AnnotationTypeFilter for the given annotation type.AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces)
Create a newAnnotationTypeFilter
for the given annotation type.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Boolean
hasAnnotation(String typeName)
protected Boolean
matchInterface(String interfaceName)
Override this to match on interface type name.protected boolean
matchSelf(MetadataReader metadataReader)
Override this to match self characteristics alone.protected Boolean
matchSuperClass(String superClassName)
Override this to match on super type name.Methods inherited from class org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
match, matchClassName
Constructor Detail
AnnotationTypeFilter
public AnnotationTypeFilter(Class<? extends Annotation> annotationType)
Create a new AnnotationTypeFilter for the given annotation type. This filter will also match meta-annotations. To disable the meta-annotation matching, use the constructor that accepts a 'considerMetaAnnotations
' argument. The filter will not match interfaces.- Parameters:
annotationType
- the annotation type to match
AnnotationTypeFilter
public AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations)
Create a new AnnotationTypeFilter for the given annotation type. The filter will not match interfaces.- Parameters:
annotationType
- the annotation type to matchconsiderMetaAnnotations
- whether to also match on meta-annotations
AnnotationTypeFilter
public AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces)
Create a newAnnotationTypeFilter
for the given annotation type.- Parameters:
annotationType
- the annotation type to matchconsiderMetaAnnotations
- whether to also match on meta-annotationsconsiderInterfaces
- whether to also match interfaces
Method Detail
matchSelf
protected boolean matchSelf(MetadataReader metadataReader)
Description copied from class:AbstractTypeHierarchyTraversingFilter
Override this to match self characteristics alone. Typically, the implementation will use a visitor to extract information to perform matching.- Overrides:
matchSelf
in classAbstractTypeHierarchyTraversingFilter
matchSuperClass
protected Boolean matchSuperClass(String superClassName)
Description copied from class:AbstractTypeHierarchyTraversingFilter
Override this to match on super type name.- Overrides:
matchSuperClass
in classAbstractTypeHierarchyTraversingFilter
matchInterface
protected Boolean matchInterface(String interfaceName)
Description copied from class:AbstractTypeHierarchyTraversingFilter
Override this to match on interface type name.- Overrides:
matchInterface
in classAbstractTypeHierarchyTraversingFilter
hasAnnotation
protected Boolean hasAnnotation(String typeName)