Class AnnotationTypeFilter
java.lang.Object
org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
org.springframework.core.type.filter.AnnotationTypeFilter
- All Implemented Interfaces:
TypeFilter
A simple
TypeFilter which matches classes with a given annotation,
checking inherited annotations as well.
By default, the matching logic mirrors that of
AnnotationUtils.getAnnotation(java.lang.reflect.AnnotatedElement, Class),
supporting annotations that are present or meta-present for a
single level of meta-annotations. The search for meta-annotations my be disabled.
Similarly, the search for annotations on interfaces may optionally be enabled.
Consult the various constructors in this class for details.
- Since:
- 2.5
- Author:
- Mark Fisher, Ramnivas Laddad, Juergen Hoeller, Sam Brannen
-
Field Summary
Fields inherited from class org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
logger -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationTypeFilter(Class<? extends Annotation> annotationType) Create a newAnnotationTypeFilterfor the given annotation type.AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations) Create a newAnnotationTypeFilterfor the given annotation type.AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces) Create a newAnnotationTypeFilterfor the given annotation type. -
Method Summary
Modifier and TypeMethodDescriptionfinal Class<? extends Annotation>Return theAnnotationthat this instance is using to filter candidates.protected BooleanhasAnnotation(String typeName) protected BooleanmatchInterface(String interfaceName) Override this to match on interface type name.protected booleanmatchSelf(MetadataReader metadataReader) Override this to match self characteristics alone.protected BooleanmatchSuperClass(String superClassName) Override this to match on super type name.Methods inherited from class org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter
match, matchClassName
-
Constructor Details
-
AnnotationTypeFilter
Create a newAnnotationTypeFilterfor the given annotation type.The 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 newAnnotationTypeFilterfor 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 newAnnotationTypeFilterfor the given annotation type.- Parameters:
annotationType- the annotation type to matchconsiderMetaAnnotations- whether to also match on meta-annotationsconsiderInterfaces- whether to also match interfaces
-
-
Method Details
-
getAnnotationType
Return theAnnotationthat this instance is using to filter candidates.- Since:
- 5.0
-
matchSelf
Description copied from class:AbstractTypeHierarchyTraversingFilterOverride this to match self characteristics alone. Typically, the implementation will use a visitor to extract information to perform matching.- Overrides:
matchSelfin classAbstractTypeHierarchyTraversingFilter
-
matchSuperClass
Description copied from class:AbstractTypeHierarchyTraversingFilterOverride this to match on super type name.- Overrides:
matchSuperClassin classAbstractTypeHierarchyTraversingFilter
-
matchInterface
Description copied from class:AbstractTypeHierarchyTraversingFilterOverride this to match on interface type name.- Overrides:
matchInterfacein classAbstractTypeHierarchyTraversingFilter
-
hasAnnotation
-