Top Description Fields Constructors Methods
com.sun.codemodel

pack-priv Class TypedAnnotationWriter<A extends Annotation, W extends JAnnotationWriter<A>>

extends Object
implements InvocationHandler, JAnnotationWriter<A extends Annotation>
Class Inheritance
All Implemented Interfaces
com.sun.codemodel.JAnnotationWriter, java.lang.reflect.InvocationHandler
Imports
java.lang.reflect.InvocationHandler, .Method, .Proxy, .Type, .ParameterizedType, .InvocationTargetException, java.lang.annotation.Annotation, java.util.Map, .HashMap

Dynamically implements the typed annotation writer interfaces.
Author
Kohsuke Kawaguchi

Field Summary

Modifier and TypeField and Description
private final Class<A>
annotation

The annotation that we are writing.

private Map<String, JAnnotationArrayMember>
arrays

Keeps track of writers for array members.

private final JAnnotationUse
use

This is what we are writing to.

private final Class<W>
writerType

The type of the writer.

Constructor Summary

AccessConstructor and Description
public
TypedAnnotationWriter(Class<A> annotation, Class<W> writer, JAnnotationUse use)

Method Summary

Modifier and TypeMethod and Description
private Object
addArrayValue(Object proxy, String name, Class<?> itemType, Class<?> expectedReturnType, Object arg)

private void
checkType(Class<?> actual, Class<?> expected)

Check if the type of the argument matches our expectation.

pack-priv static <W extends JAnnotationWriter<?>> W
create(Class<W> w, JAnnotatable annotatable)

Creates a new typed annotation writer.

private W
createProxy()

Creates a proxy and returns it.

private static Class<? extends Annotation>
public Class<A>
getAnnotationType()

Implements com.sun.codemodel.JAnnotationWriter.getAnnotationType.

The type of the annotation that this writer is writing.

public JAnnotationUse
getAnnotationUse()

Implements com.sun.codemodel.JAnnotationWriter.getAnnotationUse.

Gets the underlying annotation use object to which we are writing.

private static Method
public Object
invoke(Object proxy, Method method, Object[] args)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationback to summary
private final Class<A> annotation

The annotation that we are writing.

arraysback to summary
private Map<String, JAnnotationArrayMember> arrays

Keeps track of writers for array members. Lazily created.

useback to summary
private final JAnnotationUse use

This is what we are writing to.

writerTypeback to summary
private final Class<W> writerType

The type of the writer.

Constructor Detail

TypedAnnotationWriterback to summary
public TypedAnnotationWriter(Class<A> annotation, Class<W> writer, JAnnotationUse use)

Method Detail

addArrayValueback to summary
private Object addArrayValue(Object proxy, String name, Class<?> itemType, Class<?> expectedReturnType, Object arg)
Annotations
@SuppressWarnings:unchecked, rawtypes
checkTypeback to summary
private void checkType(Class<?> actual, Class<?> expected)

Check if the type of the argument matches our expectation. If not, report an error.

createback to summary
pack-priv static <W extends JAnnotationWriter<?>> W create(Class<W> w, JAnnotatable annotatable)

Creates a new typed annotation writer.

Annotations
@SuppressWarnings:unchecked, rawtypes
createProxyback to summary
private W createProxy()

Creates a proxy and returns it.

Annotations
@SuppressWarnings:unchecked
findAnnotationTypeback to summary
private static Class<? extends Annotation> findAnnotationType(Class<?> clazz)
Annotations
@SuppressWarnings:unchecked
getAnnotationTypeback to summary
public Class<A> getAnnotationType()

Implements com.sun.codemodel.JAnnotationWriter.getAnnotationType.

Doc from com.sun.codemodel.JAnnotationWriter.getAnnotationType.

The type of the annotation that this writer is writing.

Annotations
@Override
getAnnotationUseback to summary
public JAnnotationUse getAnnotationUse()

Implements com.sun.codemodel.JAnnotationWriter.getAnnotationUse.

Doc from com.sun.codemodel.JAnnotationWriter.getAnnotationUse.

Gets the underlying annotation use object to which we are writing.

Annotations
@Override
getOverriddenJAnnotationWriterMethodback to summary
private static Method getOverriddenJAnnotationWriterMethod(Method method)
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Annotations
@SuppressWarnings:unchecked, rawtypes
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the invoked method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the invoked method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.