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 intMaps primitiveClasses 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 intprivate intcalculateHashCode(Object element) booleanPerforms an equality check as described inAnnotation.equals(Object).inthashCode()Calculates the hash code of this annotation as described inAnnotation.hashCode().toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
primitiveWrapperMap
Maps primitiveClasses 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:
invokein interfaceInvocationHandler- Throws:
Throwable
-
annotationType
- Specified by:
annotationTypein interfaceAnnotation
-
equals
Performs an equality check as described inAnnotation.equals(Object).- Specified by:
equalsin interfaceAnnotation- Overrides:
equalsin 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:
hashCodein interfaceAnnotation- Overrides:
hashCodein classObject- Returns:
- The hash code of this annotation.
- See Also:
-
toString
- Specified by:
toStringin interfaceAnnotation- Overrides:
toStringin classObject
-
calculateHashCode
private int calculateHashCode() -
calculateHashCode
-