class AnnotationInvocationHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
private static class |
AnnotationInvocationHandler.SerializationProxy
Defines a serialization proxy used to replace instances of
AnnotationInvocationHandler in a serialized stream. |
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationType
Stores the annotation type to emulate.
|
private java.lang.reflect.Method[] |
members
Stores the members declared by
annotationType. |
private static long |
serialVersionUID
Defines the serialization id.
|
private HashMap<java.lang.String,java.lang.Object> |
valueMap
Stores the values corresponding to the annotation values.
|
| Constructor and Description |
|---|
AnnotationInvocationHandler(HashMap<java.lang.String,java.lang.Object> valueMap,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Creates a new invocation handler taking over the annotation type and the
values to return for the annotation (instance).
|
| Modifier and Type | Method and Description |
|---|---|
private void |
appendInBraces(java.lang.StringBuilder buf,
java.lang.String text)
Appends the given string in braces to
buf. |
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
private static java.lang.Object |
invoke(java.lang.reflect.Method method,
java.lang.Object instance)
Calls a method without parameters (getter) on the given
instance. |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args) |
private void |
readObject(java.io.ObjectInputStream in)
Disables typical serialization input as this should be done by
AnnotationInvocationHandler.SerializationProxy. |
java.lang.String |
toString() |
private java.lang.Object |
writeReplace()
Defines a replacement object for this in a serialized stream
(
AnnotationInvocationHandler.SerializationProxy). |
private static final long serialVersionUID
private final HashMap<java.lang.String,java.lang.Object> valueMap
private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
private final java.lang.reflect.Method[] members
annotationType.AnnotationInvocationHandler(HashMap<java.lang.String,java.lang.Object> valueMap, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
valueMap - the concrete values for the individual annotation
attributesannotationType - the annotation type to emulatepublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwablepublic java.lang.String toString()
toString in class java.lang.Objectprivate void appendInBraces(java.lang.StringBuilder buf,
java.lang.String text)
buf.buf - the buffer to append totext - the string to appendpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprivate java.lang.Object writeReplace()
throws java.io.ObjectStreamException
AnnotationInvocationHandler.SerializationProxy).java.io.ObjectStreamException - in case of any problem during serializationprivate void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
AnnotationInvocationHandler.SerializationProxy.in - the input streamjava.io.IOException - in case of any I/O problemjava.lang.ClassNotFoundException - in case that the current object cannot be
casted appropriatelyprivate static java.lang.Object invoke(java.lang.reflect.Method method,
java.lang.Object instance)
instance.method - the method to be calledinstance - the instance on which to call the method