public class AnnotationTypeFilter extends AbstractTypeHierarchyTraversingFilter
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.
logger
Constructor and 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 new
AnnotationTypeFilter for the given annotation type. |
Modifier and Type | Method and Description |
---|---|
Class<? extends Annotation> |
getAnnotationType()
Return the
Annotation that this instance is using to filter
candidates. |
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.
|
match, matchClassName
public AnnotationTypeFilter(Class<? extends Annotation> annotationType)
AnnotationTypeFilter
for 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.
annotationType
- the annotation type to matchpublic AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations)
AnnotationTypeFilter
for the given annotation type.
The filter will not match interfaces.
annotationType
- the annotation type to matchconsiderMetaAnnotations
- whether to also match on meta-annotationspublic AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces)
AnnotationTypeFilter
for the given annotation type.annotationType
- the annotation type to matchconsiderMetaAnnotations
- whether to also match on meta-annotationsconsiderInterfaces
- whether to also match interfacespublic final Class<? extends Annotation> getAnnotationType()
Annotation
that this instance is using to filter
candidates.protected boolean matchSelf(MetadataReader metadataReader)
AbstractTypeHierarchyTraversingFilter
matchSelf
in class AbstractTypeHierarchyTraversingFilter
@Nullable protected Boolean matchSuperClass(String superClassName)
AbstractTypeHierarchyTraversingFilter
matchSuperClass
in class AbstractTypeHierarchyTraversingFilter
@Nullable protected Boolean matchInterface(String interfaceName)
AbstractTypeHierarchyTraversingFilter
matchInterface
in class AbstractTypeHierarchyTraversingFilter