org.springframework.core.type.filter

Class 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().

    Since:
    2.5
    Author:
    Mark Fisher, Ramnivas Laddad, Juergen Hoeller
    • 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 match
        considerMetaAnnotations - whether to also match on meta-annotations
      • AnnotationTypeFilter

        public AnnotationTypeFilter(Class<? extends Annotation> annotationType,
                            boolean considerMetaAnnotations,
                            boolean considerInterfaces)
        Create a new AnnotationTypeFilter for the given annotation type.
        Parameters:
        annotationType - the annotation type to match
        considerMetaAnnotations - whether to also match on meta-annotations
        considerInterfaces - whether to also match interfaces