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
ConstructorsConstructorDescriptionAnnotationDetectionFieldCallback(Class<? extends Annotation> annotationType) Creates a newAnnotationDetectionFieldCallbackscanning for an annotation of the given type. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetField()Returns the detected field.Returns the field that was detected.Class<?>Returns the type of the field or throws anIllegalArgumentExceptionif no field could be found.Class<?>getType()Returns the type of the field.<T> TRetrieves the value of the field by reflection.
-
Constructor Details
-
AnnotationDetectionFieldCallback
Creates a newAnnotationDetectionFieldCallbackscanning for an annotation of the given type.- Parameters:
annotationType- must not be null.
-
-
Method Details
-
doWith
- Specified by:
doWithin interfaceReflectionUtils.FieldCallback- Throws:
IllegalArgumentExceptionIllegalAccessException
-
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 anIllegalArgumentExceptionif 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:
-