Class AnnotationTargetUtils
java.lang.Object
io.micronaut.sourcegen.bytecode.core.AnnotationTargetUtils
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 Summary
Modifier and TypeMethodDescriptionstatic Optional<RetentionPolicy> declaredRetentionOf(ObjectDef objectDef) static Optional<Set<ElementType>> declaredTargetsOf(ObjectDef objectDef) static RetentionPolicyretentionOf(AnnotationDef annotation, @Nullable ClassLoader classLoader) The retention of an annotation, resolved the way the ASM backend resolves it.static Optional<Set<ElementType>> targetsOf(AnnotationDef annotation, @Nullable ClassLoader classLoader) static Set<ElementType> toElementTypes(@Nullable Object value) Converts the model's representation of aTarget.value()member.
-
Method Details
-
targetsOf
public static Optional<Set<ElementType>> targetsOf(AnnotationDef annotation, @Nullable ClassLoader classLoader) - Parameters:
annotation- The annotationclassLoader- The fallback class loader- Returns:
- Declared targets, or empty when the annotation has no usable target declaration
-
declaredTargetsOf
- Parameters:
objectDef- An annotation definition- Returns:
- Declared targets, or empty when none can be read
-
toElementTypes
Converts the model's representation of aTarget.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 annotationclassLoader- The fallback class loader- Returns:
- Its retention
-
declaredRetentionOf
- Parameters:
objectDef- An annotation definition- Returns:
- The retention it declares, or empty when it declares none
-