- java.lang.Object
-
- io.leangen.geantyref.AnnotationInvocationHandler
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.annotation.Annotation
,java.lang.reflect.InvocationHandler
class AnnotationInvocationHandler extends java.lang.Object implements java.lang.annotation.Annotation, java.lang.reflect.InvocationHandler, java.io.Serializable
An implementation ofAnnotation
that mimics the behavior of normal annotations. It is anInvocationHandler
, meant to be used viaTypeFactory.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)
andhashCode()
and implemented as specified byAnnotation
, so instances are safe to mix with normal annotations.- See Also:
Annotation
-
-
Field Summary
Fields Modifier and Type Field 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 primitiveClass
es to their corresponding wrapperClass
.private static long
serialVersionUID
private java.util.Map<java.lang.String,java.lang.Object>
values
-
Constructor Summary
Constructors Constructor Description AnnotationInvocationHandler(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,java.lang.Object> values)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 inAnnotation.equals(Object)
.int
hashCode()
Calculates the hash code of this annotation as described inAnnotation.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()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
primitiveWrapperMap
private static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> primitiveWrapperMap
Maps primitiveClass
es to their corresponding wrapperClass
.
-
annotationType
private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
-
values
private final java.util.Map<java.lang.String,java.lang.Object> values
-
hashCode
private final int hashCode
-
-
Constructor Detail
-
AnnotationInvocationHandler
AnnotationInvocationHandler(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.util.Map<java.lang.String,java.lang.Object> values) throws AnnotationFormatException
- Throws:
AnnotationFormatException
-
-
Method Detail
-
normalize
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
- Throws:
AnnotationFormatException
-
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
-
annotationType
public java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
- Specified by:
annotationType
in interfacejava.lang.annotation.Annotation
-
equals
public boolean equals(java.lang.Object other)
Performs an equality check as described inAnnotation.equals(Object)
.- Specified by:
equals
in interfacejava.lang.annotation.Annotation
- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- The object to compare- Returns:
- Whether the given object is equal to this annotation or not
- See Also:
Annotation.equals(Object)
-
hashCode
public int hashCode()
Calculates the hash code of this annotation as described inAnnotation.hashCode()
.- Specified by:
hashCode
in interfacejava.lang.annotation.Annotation
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code of this annotation.
- See Also:
Annotation.hashCode()
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.annotation.Annotation
- Overrides:
toString
in classjava.lang.Object
-
calculateHashCode
private int calculateHashCode()
-
calculateHashCode
private int calculateHashCode(java.lang.Object element)
-
-