- 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.SerializableAn implementation ofAnnotationthat 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,
AnnotationFormatExceptionis 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>annotationTypeprivate inthashCodeprivate static java.util.Map<java.lang.Class<?>,java.lang.Class<?>>primitiveWrapperMapMaps primitiveClasses to their corresponding wrapperClass.private static longserialVersionUIDprivate 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 intcalculateHashCode()private intcalculateHashCode(java.lang.Object element)booleanequals(java.lang.Object other)Performs an equality check as described inAnnotation.equals(Object).inthashCode()Calculates the hash code of this annotation as described inAnnotation.hashCode().java.lang.Objectinvoke(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.StringtoString()
-
-
-
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 primitiveClasses 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:
invokein interfacejava.lang.reflect.InvocationHandler- Throws:
java.lang.Throwable
-
annotationType
public java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
- Specified by:
annotationTypein interfacejava.lang.annotation.Annotation
-
equals
public boolean equals(java.lang.Object other)
Performs an equality check as described inAnnotation.equals(Object).- Specified by:
equalsin interfacejava.lang.annotation.Annotation- Overrides:
equalsin 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:
hashCodein interfacejava.lang.annotation.Annotation- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash code of this annotation.
- See Also:
Annotation.hashCode()
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.annotation.Annotation- Overrides:
toStringin classjava.lang.Object
-
calculateHashCode
private int calculateHashCode()
-
calculateHashCode
private int calculateHashCode(java.lang.Object element)
-
-