@Value can be used as aliased meta-annotation
Issue: SPR-13603
This commit is contained in:
@@ -97,6 +97,35 @@ public class AnnotatedElementUtils {
|
||||
private static final Boolean CONTINUE = null;
|
||||
|
||||
|
||||
/**
|
||||
* Build an adapted {@link AnnotatedElement} for the given annotations,
|
||||
* typically for use with other methods on {@link AnnotatedElementUtils}.
|
||||
* @param annotations the annotations to expose through the {@code AnnotatedElement}
|
||||
* @since 4.3
|
||||
*/
|
||||
public static AnnotatedElement forAnnotations(final Annotation... annotations) {
|
||||
return new AnnotatedElement() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
||||
for (Annotation ann : annotations) {
|
||||
if (ann.annotationType() == annotationClass) {
|
||||
return (T) ann;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Annotation[] getAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
@Override
|
||||
public Annotation[] getDeclaredAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully qualified class names of all meta-annotation types
|
||||
* <em>present</em> on the annotation (of the specified {@code annotationType})
|
||||
|
||||
Reference in New Issue
Block a user