Interface AnnotationAccessor

All Known Implementing Classes:
AnnotationAccessor.NullAnnotationAccessor

@API(status=STABLE, since="1.2.0") public interface AnnotationAccessor
Managed access for Annotation instances
Since:
1.2.0
  • Method Details

    • empty

      @API(status=STABLE, since="1.3.0") static @NonNull AnnotationAccessor empty()
      Get a AnnotationAccessor that cannot access any annotations
      Returns:
      Empty annotation accessor
      Since:
      1.3.0
    • of

      static @NonNull AnnotationAccessor of(@NonNull AnnotatedElement element)
      Get a AnnotationAccessor instance for a AnnotatedElement, such as a Class or a Method. 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

      @API(status=STABLE, since="1.4.0") static @NonNull AnnotationAccessor of(@NonNull AnnotationAccessor @NonNull ... accessors)
      Get a AnnotationAccessor instance that delegates to multiple AnnotatedElement 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 Annotation> @Nullable A annotation(@NonNull Class<A> clazz)
      Get an annotation instance, if it's present. If the annotation isn't available, this will return null
      Type Parameters:
      A - Annotation type
      Parameters:
      clazz - Annotation class
      Returns:
      Annotation instance, or null
    • annotations

      @NonNull Collection<@NonNull Annotation> annotations()
      Get an immutable collection containing all of the annotations that are accessible using the annotation accessor
      Returns:
      Immutable collection of annotations