Package 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, Mark Paluch, Johannes Englmeier
-
Constructor Summary
ConstructorDescriptionAnnotationDetectionFieldCallback
(Class<? extends Annotation> annotationType) Creates a newAnnotationDetectionFieldCallback
scanning for an annotation of the given type. -
Method Summary
Modifier and TypeMethodDescriptionvoid
getField()
Returns the detected field.Returns the field that was detected.Class<?>
Returns the type of the field or throws anIllegalArgumentException
if no field could be found.Class<?>
getType()
Returns the type of the field.<T> T
Retrieves the value of the field by reflection.
-
Constructor Details
-
AnnotationDetectionFieldCallback
Creates a newAnnotationDetectionFieldCallback
scanning for an annotation of the given type.- Parameters:
annotationType
- must not be null.
-
-
Method Details
-
doWith
- Specified by:
doWith
in interfaceReflectionUtils.FieldCallback
- Throws:
IllegalArgumentException
IllegalAccessException
-
getField
Returns the detected field.- Returns:
- the field
-
getRequiredField
Returns the field that was detected.- Returns:
- Throws:
IllegalStateException
- in case no field with the configured annotation was found.
-
getType
Returns the type of the field.- Returns:
-
getRequiredType
Returns the type of the field or throws anIllegalArgumentException
if no field could be found.- Returns:
- Throws:
IllegalStateException
- in case no field with the configured annotation was found.
-
getValue
Retrieves the value of the field by reflection.- Parameters:
source
- must not be null.- Returns:
-