org.springframework.data.util

## Class AnnotationDetectionMethodCallback<A extends Annotation>

- java.lang.Object
- - org.springframework.data.util.AnnotationDetectionMethodCallback<A>

All Implemented Interfaces:
  ReflectionUtils.MethodCallback

    public class AnnotationDetectionMethodCallback<A extends Annotation>
    extends Object
    implements ReflectionUtils.MethodCallback

`ReflectionUtils.MethodCallback` to find annotations of a given type.

Author:
  Oliver Gierke, Christoph Strobl

### Constructor Summary

Constructors
Constructor and Description
`AnnotationDetectionMethodCallback(Class<A> annotationType)` Creates a new `AnnotationDetectionMethodCallback` for the given annotation type.
`AnnotationDetectionMethodCallback(Class<A> annotationType, boolean enforceUniqueness)` Creates a new `AnnotationDetectionMethodCallback` for the given annotation type.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `doWith(Method method)`
`A` `getAnnotation()`
`Method` `getMethod()`
`Method` `getRequiredMethod()` Returns the method with the configured annotation.
`boolean` `hasFoundAnnotation()` Returns whether an annotation was found.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AnnotationDetectionMethodCallback

    public AnnotationDetectionMethodCallback(Class<A> annotationType)

Creates a new `AnnotationDetectionMethodCallback` for the given annotation type.

Parameters:
  `annotationType` - must not be null.

#### AnnotationDetectionMethodCallback

    public AnnotationDetectionMethodCallback(Class<A> annotationType,
                                             boolean enforceUniqueness)

Creates a new `AnnotationDetectionMethodCallback` for the given annotation type.

Parameters:
  `annotationType` - must not be null.
  `enforceUniqueness` - whether to fail if multiple methods with the annotation are found.

### Method Detail

#### getMethod

    @Nullable
    public Method getMethod()

Returns:
  the method

#### getRequiredMethod

    public Method getRequiredMethod()

Returns the method with the configured annotation.

Returns:
Throws:
  `IllegalStateException` - in case no method with the configured annotation was found.

#### getAnnotation

    @Nullable
    public A getAnnotation()

Returns:
  the annotation

#### hasFoundAnnotation

    public boolean hasFoundAnnotation()

Returns whether an annotation was found.

Returns:

#### doWith

    public void doWith(Method method)
                throws IllegalArgumentException,
                       IllegalAccessException

Specified by:
  `doWith` in interface `ReflectionUtils.MethodCallback`
Throws:
  `IllegalArgumentException`
  `IllegalAccessException`