class AnnotationInvocationHandler
extends java.lang.Object
implements java.lang.annotation.Annotation, java.lang.reflect.InvocationHandler, java.io.Serializable
Annotation
that mimics the behavior of normal annotations.
It is an InvocationHandler
, meant to be used via TypeFactory.annotation(Class, Map)
.
The constructor checks that the all the elements required by the annotation interface are provided
and that the types are compatible. If extra elements are provided, they are ignored.
If a value is of an incompatible type is provided or no value is provided for an element
without a default value, AnnotationFormatException
is thrown.
Note: equals(Object)
and hashCode()
and implemented as specified
by Annotation
, so instances are safe to mix with normal annotations.
Annotation
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationType |
private int |
hashCode |
private static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
primitiveWrapperMap
Maps primitive
Class es to their corresponding wrapper Class . |
private static long |
serialVersionUID |
private java.util.Map<java.lang.String,java.lang.Object> |
values |
Constructor and Description |
---|
AnnotationInvocationHandler(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.util.Map<java.lang.String,java.lang.Object> values) |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationType() |
private int |
calculateHashCode() |
private int |
calculateHashCode(java.lang.Object element) |
boolean |
equals(java.lang.Object other)
Performs an equality check as described in
Annotation.equals(Object) . |
int |
hashCode()
Calculates the hash code of this annotation as described in
Annotation.hashCode() . |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args) |
(package private) static java.util.Map<java.lang.String,java.lang.Object> |
normalize(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.util.Map<java.lang.String,java.lang.Object> values) |
java.lang.String |
toString() |
private static final long serialVersionUID
private static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> primitiveWrapperMap
Class
es to their corresponding wrapper Class
.private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
private final java.util.Map<java.lang.String,java.lang.Object> values
private final int hashCode
AnnotationInvocationHandler(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,java.lang.Object> values) throws AnnotationFormatException
AnnotationFormatException
static java.util.Map<java.lang.String,java.lang.Object> normalize(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,java.lang.Object> values) throws AnnotationFormatException
AnnotationFormatException
public 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.InvocationHandler
java.lang.Throwable
public java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
annotationType
in interface java.lang.annotation.Annotation
public boolean equals(java.lang.Object other)
Annotation.equals(Object)
.equals
in interface java.lang.annotation.Annotation
equals
in class java.lang.Object
other
- The object to compareAnnotation.equals(Object)
public int hashCode()
Annotation.hashCode()
.hashCode
in interface java.lang.annotation.Annotation
hashCode
in class java.lang.Object
Annotation.hashCode()
public java.lang.String toString()
toString
in interface java.lang.annotation.Annotation
toString
in class java.lang.Object
private int calculateHashCode()
private int calculateHashCode(java.lang.Object element)