Class AnnotationType


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

      Fields 
      Modifier and Type Field Description
      private static java.lang.ClassValue<AnnotationType> ANNOTATION_TYPES  
      private boolean inherited
      Whether this annotation type is inherited.
      private java.util.Map<java.lang.String,​java.lang.Object> memberDefaults
      Member name -> default value mapping.
      private java.util.Map<java.lang.String,​java.lang.reflect.Method> members
      Member name -> Method object mapping.
      private java.util.Map<java.lang.String,​java.lang.Class<?>> memberTypes
      Member name -> type mapping.
      private java.lang.annotation.RetentionPolicy retention
      The retention policy for this annotation type.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private AnnotationType​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Sole constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static AnnotationType getInstance​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Returns an AnnotationType instance for the specified annotation type.
      static java.lang.Class<?> invocationHandlerReturnType​(java.lang.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).
      boolean isInherited()
      Returns true if this annotation type is inherited.
      java.util.Map<java.lang.String,​java.lang.Object> memberDefaults()
      Returns the default values for this annotation type (Member name -> default value mapping).
      java.util.Map<java.lang.String,​java.lang.reflect.Method> members()
      Returns members of this annotation type (member name -> associated Method object mapping).
      java.util.Map<java.lang.String,​java.lang.Class<?>> memberTypes()
      Returns member types for this annotation type (member name -> type mapping).
      java.lang.annotation.RetentionPolicy retention()
      Returns the retention policy for this annotation type.
      java.lang.String toString()
      For debugging.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ANNOTATION_TYPES

        private static final java.lang.ClassValue<AnnotationType> ANNOTATION_TYPES
      • memberTypes

        private final java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.String,​java.lang.Object> memberDefaults
        Member name -> default value mapping.
      • members

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

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

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

      • AnnotationType

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

      • getInstance

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

        public static java.lang.Class<?> invocationHandlerReturnType​(java.lang.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 java.util.Map<java.lang.String,​java.lang.Class<?>> memberTypes()
        Returns member types for this annotation type (member name -> type mapping).
      • members

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

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

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

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

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