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) |
Class<?> |
getRequiredType()
Returns the type of the field or throws an
IllegalArgumentException if no field could be found. |
Optional<Class<?>> |
getType()
Returns the type of the field.
|
<T> Optional<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 Class<?> getRequiredType()
IllegalArgumentException
if no field could be found.IllegalStateException
Copyright © 2011-2016–2017 Pivotal Software, Inc.. All rights reserved.