public class AnnotationDetectionFieldCallback extends Object implements ReflectionUtils.FieldCallback
ReflectionUtils.FieldCallback
that will inspect each field for a given annotation. This field's type can then be accessed
afterwards.Constructor and Description |
---|
AnnotationDetectionFieldCallback(Class<? extends Annotation> annotationType)
Creates a new
AnnotationDetectionFieldCallback scanning for an annotation of the given type. |
Modifier and Type | Method and Description |
---|---|
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.
|
public AnnotationDetectionFieldCallback(Class<? extends Annotation> annotationType)
AnnotationDetectionFieldCallback
scanning for an annotation of the given type.annotationType
- must not be null.public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException
doWith
in interface ReflectionUtils.FieldCallback
IllegalArgumentException
IllegalAccessException
public Field getRequiredField()
IllegalStateException
- in case no field with the configured annotation was found.public Class<?> getRequiredType()
IllegalArgumentException
if no field could be found.IllegalStateException
- in case no field with the configured annotation was found.Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.