Interface AnnotationAccessor
-
- All Known Implementing Classes:
AnnotationAccessor.NullAnnotationAccessor
public interface AnnotationAccessor
Managed access forAnnotation
instances- Since:
- 1.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AnnotationAccessor.NullAnnotationAccessor
Annotation accessor that cannot access any annotations
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <A extends java.lang.annotation.Annotation>
@Nullable Aannotation(@NonNull java.lang.Class<A> clazz)
Get an annotation instance, if it's present.@NonNull java.util.Collection<@NonNull java.lang.annotation.Annotation>
annotations()
Get an immutable collection containing all of the annotations that are accessible using the annotation accessorstatic @NonNull AnnotationAccessor
empty()
Get aAnnotationAccessor
that cannot access any annotationsstatic @NonNull AnnotationAccessor
of(@NonNull AnnotationAccessor @NonNull ... accessors)
Get aAnnotationAccessor
instance that delegates to multipleAnnotatedElement
instances.static @NonNull AnnotationAccessor
of(@NonNull java.lang.reflect.AnnotatedElement element)
-
-
-
Method Detail
-
empty
static @NonNull AnnotationAccessor empty()
Get aAnnotationAccessor
that cannot access any annotations- Returns:
- Empty annotation accessor
- Since:
- 1.3.0
-
of
static @NonNull AnnotationAccessor of(@NonNull java.lang.reflect.AnnotatedElement element)
Get aAnnotationAccessor
instance for aAnnotatedElement
, such as aClass
or aMethod
. This instance can then be used as a proxy for retrieving the element's annotations- Parameters:
element
- Annotated element that will be proxied by the accessor- Returns:
- Annotation accessor proxying the given annotated element
-
of
static @NonNull AnnotationAccessor of(@NonNull AnnotationAccessor @NonNull ... accessors)
Get aAnnotationAccessor
instance that delegates to multipleAnnotatedElement
instances. The first accessor that provides a requested annotation will always be used- Parameters:
accessors
- The accessor to delegate to- Returns:
- Annotation accessor that delegates to the given accessors (using their natural ordering)
- Since:
- 1.4.0
-
annotation
<A extends java.lang.annotation.Annotation> @Nullable A annotation(@NonNull java.lang.Class<A> clazz)
Get an annotation instance, if it's present. If the annotation isn't available, this will returnnull
- Type Parameters:
A
- Annotation type- Parameters:
clazz
- Annotation class- Returns:
- Annotation instance, or
null
-
annotations
@NonNull java.util.Collection<@NonNull java.lang.annotation.Annotation> annotations()
Get an immutable collection containing all of the annotations that are accessible using the annotation accessor- Returns:
- Immutable collection of annotations
-
-