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

    Since:
    2.5
    Author:
    Mark Fisher, Ramnivas Laddad, Juergen Hoeller
    • Constructor Summary

      Constructors 
      Constructor and Description
      AnnotationTypeFilter(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      Create a new AnnotationTypeFilter for the given annotation type.
      AnnotationTypeFilter(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean considerMetaAnnotations)
      Create a new AnnotationTypeFilter for the given annotation type.
      AnnotationTypeFilter(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces)
      Create a new AnnotationTypeFilter for the given annotation type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Class<? extends java.lang.annotation.Annotation> getAnnotationType()
      Return the Annotation that this instance is using to filter candidates.
      protected java.lang.Boolean hasAnnotation(java.lang.String typeName) 
      protected java.lang.Boolean matchInterface(java.lang.String interfaceName)
      Override this to match on interface type name.
      protected boolean matchSelf(MetadataReader metadataReader)
      Override this to match self characteristics alone.
      protected java.lang.Boolean matchSuperClass(java.lang.String superClassName)
      Override this to match on super type name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnnotationTypeFilter

        public AnnotationTypeFilter(java.lang.Class<? extends java.lang.annotation.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(java.lang.Class<? extends java.lang.annotation.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(java.lang.Class<? extends java.lang.annotation.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