org.springframework.data.util

## Class AnnotationDetectionFieldCallback

- java.lang.Object
- - org.springframework.data.util.AnnotationDetectionFieldCallback

All Implemented Interfaces:
  ReflectionUtils.FieldCallback

    public class AnnotationDetectionFieldCallback
    extends Object
    implements ReflectionUtils.FieldCallback

A `ReflectionUtils.FieldCallback` that will inspect each field for a given annotation. This field's type can then be accessed afterwards.

Author:
  Oliver Gierke, Christoph Strobl

### Constructor Summary

Constructors
Constructor and Description
`AnnotationDetectionFieldCallback(Class<? extends Annotation> annotationType)` Creates a new `AnnotationDetectionFieldCallback` scanning for an annotation of the given type.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `doWith(Field field)`
`Field` `getField()` Returns the detected field.
`Field` `getRequiredField()` Returns the field that was detected.
`Class<?>` `getRequiredType()` Returns the type of the field or throws an `IllegalArgumentException` if no field could be found.
`Class<?>` `getType()` Returns the type of the field.
`<T> T` `getValue(Object source)` Retrieves the value of the field by reflection.

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

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

### Constructor Detail

#### AnnotationDetectionFieldCallback

    public AnnotationDetectionFieldCallback(Class<? extends Annotation> annotationType)

Creates a new `AnnotationDetectionFieldCallback` scanning for an annotation of the given type.

Parameters:
  `annotationType` - must not be null.

### Method Detail

#### doWith

    public void doWith(Field field)
                throws IllegalArgumentException,
                       IllegalAccessException

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

#### getField

    @Nullable
    public Field getField()

Returns the detected field.

Returns:
  the field

#### getRequiredField

    public Field getRequiredField()

Returns the field that was detected.

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

#### getType

    @Nullable
    public Class<?> getType()

Returns the type of the field.

Returns:

#### getRequiredType

    public Class<?> getRequiredType()

Returns the type of the field or throws an `IllegalArgumentException` if no field could be found.

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

#### getValue

    @Nullable
    public <T> T getValue(Object source)

Retrieves the value of the field by reflection.

Parameters:
  `source` - must not be null.
Returns: