Class AnnotationType

java.lang.Object
com.strobel.reflection.emit.AnnotationType

final class AnnotationType extends Object
Represents an annotation type at run time. Used to type-check annotations and apply member defaults.
Since:
1.5
  • Field Details

    • ANNOTATION_TYPES

      private static final ClassValue<AnnotationType> ANNOTATION_TYPES
    • memberTypes

      private final Map<String,Class<?>> memberTypes
      Member name -> type mapping. Note that primitive types are represented by the class objects for the corresponding wrapper types. This matches the return value that must be used for a dynamic proxy, allowing for a simple isInstance test.
    • memberDefaults

      private final Map<String,Object> memberDefaults
      Member name -> default value mapping.
    • members

      private final Map<String,Method> members
      Member name -> Method object mapping. This (and its associated accessor) are used only to generate AnnotationTypeMismatchExceptions.
    • retention

      private final RetentionPolicy retention
      The retention policy for this annotation type.
    • inherited

      private final boolean inherited
      Whether this annotation type is inherited.
  • Constructor Details

    • AnnotationType

      private AnnotationType(Class<? extends Annotation> annotationClass)
      Sole constructor.
      Parameters:
      annotationClass - the class object for the annotation type
      Throws:
      IllegalArgumentException - if the specified class object for does not represent a valid annotation type
  • Method Details

    • getInstance

      public static AnnotationType getInstance(Class<? extends Annotation> annotationClass)
      Returns an AnnotationType instance for the specified annotation type.
      Throws:
      IllegalArgumentException - if the specified class object for does not represent a valid annotation type
    • invocationHandlerReturnType

      public static Class<?> invocationHandlerReturnType(Class<?> type)
      Returns the type that must be returned by the invocation handler of a dynamic proxy in order to have the dynamic proxy return the specified type (which is assumed to be a legal member type for an annotation).
    • memberTypes

      public Map<String,Class<?>> memberTypes()
      Returns member types for this annotation type (member name -> type mapping).
    • members

      public Map<String,Method> members()
      Returns members of this annotation type (member name -> associated Method object mapping).
    • memberDefaults

      public Map<String,Object> memberDefaults()
      Returns the default values for this annotation type (Member name -> default value mapping).
    • retention

      public RetentionPolicy retention()
      Returns the retention policy for this annotation type.
    • isInherited

      public boolean isInherited()
      Returns true if this annotation type is inherited.
    • toString

      public String toString()
      For debugging.
      Overrides:
      toString in class Object