org.springframework.aop.support.annotation

Class AnnotationMethodMatcher

  • All Implemented Interfaces:
    MethodMatcher


    public class AnnotationMethodMatcher
    extends StaticMethodMatcher
    Simple MethodMatcher that looks for a specific Java 5 annotation being present on a method (checking both the method on the invoked interface, if any, and the corresponding method on the target class).
    Since:
    2.0
    Author:
    Juergen Hoeller
    See Also:
    AnnotationMatchingPointcut
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object other) 
      int hashCode() 
      boolean matches(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
      Perform static checking whether the given method matches.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AnnotationMethodMatcher

        public AnnotationMethodMatcher(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Create a new AnnotationClassFilter for the given annotation type.
        Parameters:
        annotationType - the annotation type to look for
      • AnnotationMethodMatcher

        public AnnotationMethodMatcher(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                                       boolean checkInherited)
        Create a new AnnotationClassFilter for the given annotation type.
        Parameters:
        annotationType - the annotation type to look for
        checkInherited - whether to also check the superclasses and interfaces as well as meta-annotations for the annotation type (i.e. whether to use AnnotatedElementUtils.hasAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>) semantics instead of standard Java AccessibleObject.isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>))
        Since:
        5.0
    • Method Detail

      • matches

        public boolean matches(java.lang.reflect.Method method,
                               java.lang.Class<?> targetClass)
        Description copied from interface: MethodMatcher
        Perform static checking whether the given method matches.

        If this returns false or if the MethodMatcher.isRuntime() method returns false, no runtime check (i.e. no MethodMatcher.matches(java.lang.reflect.Method, Class, Object[]) call) will be made.

        Parameters:
        method - the candidate method
        targetClass - the target class
        Returns:
        whether or not this method matches statically
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object