java.lang.Object
io.leangen.geantyref.AnnotationInvocationHandler
- All Implemented Interfaces:
Serializable
,Annotation
,InvocationHandler
class AnnotationInvocationHandler
extends Object
implements Annotation, InvocationHandler, Serializable
An implementation of
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class
<? extends Annotation> private final int
Maps primitiveClass
es to their corresponding wrapperClass
.private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationInvocationHandler
(Class<? extends Annotation> annotationType, Map<String, Object> values) -
Method Summary
Modifier and TypeMethodDescriptionClass
<? extends Annotation> private int
private int
calculateHashCode
(Object element) boolean
Performs an equality check as described inAnnotation.equals(Object)
.int
hashCode()
Calculates the hash code of this annotation as described inAnnotation.hashCode()
.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
primitiveWrapperMap
Maps primitiveClass
es to their corresponding wrapperClass
. -
annotationType
-
values
-
hashCode
private final int hashCode
-
-
Constructor Details
-
AnnotationInvocationHandler
AnnotationInvocationHandler(Class<? extends Annotation> annotationType, Map<String, Object> values) throws AnnotationFormatException- Throws:
AnnotationFormatException
-
-
Method Details
-
normalize
static Map<String,Object> normalize(Class<? extends Annotation> annotationType, Map<String, Object> values) throws AnnotationFormatException- Throws:
AnnotationFormatException
-
invoke
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
annotationType
- Specified by:
annotationType
in interfaceAnnotation
-
equals
Performs an equality check as described inAnnotation.equals(Object)
.- Specified by:
equals
in interfaceAnnotation
- Overrides:
equals
in classObject
- Parameters:
other
- The object to compare- Returns:
- Whether the given object is equal to this annotation or not
- See Also:
-
hashCode
public int hashCode()Calculates the hash code of this annotation as described inAnnotation.hashCode()
.- Specified by:
hashCode
in interfaceAnnotation
- Overrides:
hashCode
in classObject
- Returns:
- The hash code of this annotation.
- See Also:
-
toString
- Specified by:
toString
in interfaceAnnotation
- Overrides:
toString
in classObject
-
calculateHashCode
private int calculateHashCode() -
calculateHashCode
-