Class TypedAnnotationWriter<A extends java.lang.annotation.Annotation,​W extends JAnnotationWriter<A>>

  • All Implemented Interfaces:
    JAnnotationWriter<A>, java.lang.reflect.InvocationHandler

    class TypedAnnotationWriter<A extends java.lang.annotation.Annotation,​W extends JAnnotationWriter<A>>
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler, JAnnotationWriter<A>
    Dynamically implements the typed annotation writer interfaces.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<A> annotation
      The annotation that we are writing.
      private java.util.Map<java.lang.String,​JAnnotationArrayMember> arrays
      Keeps track of writers for array members.
      private JAnnotationUse use
      This is what we are writing to.
      private java.lang.Class<W> writerType
      The type of the writer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.Object addArrayValue​(java.lang.Object proxy, java.lang.String name, java.lang.Class itemType, java.lang.Class expectedReturnType, java.lang.Object arg)  
      private void checkType​(java.lang.Class<?> actual, java.lang.Class<?> expected)
      Check if the type of the argument matches our expectation.
      (package private) static <W extends JAnnotationWriter<?>>
      W
      create​(java.lang.Class<W> w, JAnnotatable annotatable)
      Creates a new typed annotation writer.
      private W createProxy()
      Creates a proxy and returns it.
      private static java.lang.Class<? extends java.lang.annotation.Annotation> findAnnotationType​(java.lang.Class<?> clazz)  
      java.lang.Class<A> getAnnotationType()
      The type of the annotation that this writer is writing.
      JAnnotationUse getAnnotationUse()
      Gets the underlying annotation use object to which we are writing.
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)  
      • Methods inherited from class java.lang.Object

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

      • use

        private final JAnnotationUse use
        This is what we are writing to.
      • annotation

        private final java.lang.Class<A extends java.lang.annotation.Annotation> annotation
        The annotation that we are writing.
      • writerType

        private final java.lang.Class<W extends JAnnotationWriter<A>> writerType
        The type of the writer.
      • arrays

        private java.util.Map<java.lang.String,​JAnnotationArrayMember> arrays
        Keeps track of writers for array members. Lazily created.
    • Constructor Detail

      • TypedAnnotationWriter

        public TypedAnnotationWriter​(java.lang.Class<A> annotation,
                                     java.lang.Class<W> writer,
                                     JAnnotationUse use)
    • Method Detail

      • getAnnotationType

        public java.lang.Class<A> getAnnotationType()
        Description copied from interface: JAnnotationWriter
        The type of the annotation that this writer is writing.
        Specified by:
        getAnnotationType in interface JAnnotationWriter<A extends java.lang.annotation.Annotation>
      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.Throwable
      • addArrayValue

        private java.lang.Object addArrayValue​(java.lang.Object proxy,
                                               java.lang.String name,
                                               java.lang.Class itemType,
                                               java.lang.Class expectedReturnType,
                                               java.lang.Object arg)
      • checkType

        private void checkType​(java.lang.Class<?> actual,
                               java.lang.Class<?> expected)
        Check if the type of the argument matches our expectation. If not, report an error.
      • createProxy

        private W createProxy()
        Creates a proxy and returns it.
      • create

        static <W extends JAnnotationWriter<?>> W create​(java.lang.Class<W> w,
                                                         JAnnotatable annotatable)
        Creates a new typed annotation writer.
      • findAnnotationType

        private static java.lang.Class<? extends java.lang.annotation.Annotation> findAnnotationType​(java.lang.Class<?> clazz)