Class AnnotationTargetUtils

java.lang.Object
io.micronaut.sourcegen.bytecode.core.AnnotationTargetUtils

@Internal public final class AnnotationTargetUtils extends Object
Resolves Target metadata for annotations represented by the Sourcegen model.

Annotation-processing class elements are checked before class loading because an annotation type may be one of the source files currently being compiled.

Since:
2.2
  • Method Details

    • targetsOf

      public static Optional<Set<ElementType>> targetsOf(AnnotationDef annotation, @Nullable ClassLoader classLoader)
      Parameters:
      annotation - The annotation
      classLoader - The fallback class loader
      Returns:
      Declared targets, or empty when the annotation has no usable target declaration
    • declaredTargetsOf

      public static Optional<Set<ElementType>> declaredTargetsOf(ObjectDef objectDef)
      Parameters:
      objectDef - An annotation definition
      Returns:
      Declared targets, or empty when none can be read
    • toElementTypes

      public static Set<ElementType> toElementTypes(@Nullable Object value)
      Converts the model's representation of a Target.value() member.
      Parameters:
      value - The member value
      Returns:
      Element types
    • retentionOf

      public static RetentionPolicy retentionOf(AnnotationDef annotation, @Nullable ClassLoader classLoader)
      The retention of an annotation, resolved the way the ASM backend resolves it.
      Parameters:
      annotation - The annotation
      classLoader - The fallback class loader
      Returns:
      Its retention
    • declaredRetentionOf

      public static Optional<RetentionPolicy> declaredRetentionOf(ObjectDef objectDef)
      Parameters:
      objectDef - An annotation definition
      Returns:
      The retention it declares, or empty when it declares none