Package org.springframework.aop.support.annotation

# Class AnnotationMethodMatcher

java.lang.Object
org.springframework.aop.support.StaticMethodMatcher
org.springframework.aop.support.annotation.AnnotationMethodMatcher

All Implemented Interfaces:
  `MethodMatcher`

public class AnnotationMethodMatcher extends StaticMethodMatcher
Simple `MethodMatcher` that looks for a specific 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, Sam Brannen
See Also:
  - `AnnotationMatchingPointcut`

## Field Summary

### Fields inherited from interface org.springframework.aop.MethodMatcher

`TRUE`

## Constructor Summary

Constructors
Constructor
Description
`AnnotationMethodMatcher(Class<? extends Annotation> annotationType)`
Create a new AnnotationClassFilter for the given annotation type.
`AnnotationMethodMatcher(Class<? extends Annotation> annotationType, boolean checkInherited)`
Create a new AnnotationClassFilter for the given annotation type.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object other)`
`int`
`hashCode()`
`boolean`
`matches(Method method, Class<?> targetClass)`
Perform static checking to determine whether the given method matches.
`String`
`toString()`

### Methods inherited from class org.springframework.aop.support.StaticMethodMatcher

`isRuntime, matches`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### AnnotationMethodMatcher

public AnnotationMethodMatcher(Class<? extends Annotation> annotationType)
Create a new AnnotationClassFilter for the given annotation type.

Parameters:
  `annotationType` - the annotation type to look for

### AnnotationMethodMatcher

public AnnotationMethodMatcher(Class<? extends 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 Details

### matches

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

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

Parameters:
  `method` - the candidate method
  `targetClass` - the target class
Returns:
  whether this method matches statically

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`