Package com.sun.codemodel
Class TypedAnnotationWriter<A extends java.lang.annotation.Annotation,W extends JAnnotationWriter<A>>
- java.lang.Object
-
- com.sun.codemodel.TypedAnnotationWriter<A,W>
-
- 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.
-
Constructor Summary
Constructors Constructor Description TypedAnnotationWriter(java.lang.Class<A> annotation, java.lang.Class<W> writer, JAnnotationUse use)
-
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<?>>
Wcreate(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)
-
-
-
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
-
getAnnotationUse
public JAnnotationUse getAnnotationUse()
Description copied from interface:JAnnotationWriter
Gets the underlying annotation use object to which we are writing.- Specified by:
getAnnotationUse
in interfaceJAnnotationWriter<A extends java.lang.annotation.Annotation>
-
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 interfaceJAnnotationWriter<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 interfacejava.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)
-
-