T
- The type of the handled annotation.public static class AnnotationDescription.AnnotationInvocationHandler<T extends java.lang.annotation.Annotation>
extends java.lang.Object
implements java.lang.reflect.InvocationHandler
InvocationHandler
for implementing annotations.Modifier and Type | Class and Description |
---|---|
protected static class |
AnnotationDescription.AnnotationInvocationHandler.MissingValue
Represents a missing annotation property which is not represented by a default value.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationType
The loaded annotation type.
|
private static java.lang.String |
EQUALS
The name of the
Object.equals(Object) method. |
private static java.lang.String |
HASH_CODE
The name of the
Object.hashCode() method. |
private static java.lang.Object[] |
NO_ARGUMENTS
An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
|
private static java.lang.String |
TO_STRING
The name of the
Object.toString() method. |
private java.util.LinkedHashMap<java.lang.reflect.Method,AnnotationValue.Loaded<?>> |
values
A sorted list of values of this annotation.
|
Modifier | Constructor and Description |
---|---|
protected |
AnnotationInvocationHandler(java.lang.Class<T> annotationType,
java.util.LinkedHashMap<java.lang.reflect.Method,AnnotationValue.Loaded<?>> values)
Creates a new invocation handler.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.Class<?> |
asWrapper(java.lang.Class<?> type)
Resolves any primitive type to its wrapper type.
|
private static AnnotationValue<?,?> |
defaultValueOf(java.lang.reflect.Method method)
Creates a default value for the given method.
|
boolean |
equals(java.lang.Object other) |
private boolean |
equalsRepresentation(java.lang.Object self,
java.lang.Object other)
Checks if another instance is equal to this instance.
|
int |
hashCode() |
private int |
hashCodeRepresentation()
Returns the hash code of the represented annotation.
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] argument) |
static <S extends java.lang.annotation.Annotation> |
of(java.lang.ClassLoader classLoader,
java.lang.Class<S> annotationType,
java.util.Map<java.lang.String,? extends AnnotationValue<?,?>> values)
Creates a proxy instance for the supplied annotation type and values.
|
protected java.lang.String |
toStringRepresentation()
Returns the string representation of the represented annotation.
|
private static final java.lang.String HASH_CODE
Object.hashCode()
method.private static final java.lang.String EQUALS
Object.equals(Object)
method.private static final java.lang.String TO_STRING
Object.toString()
method.private static final java.lang.Object[] NO_ARGUMENTS
private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
private final java.util.LinkedHashMap<java.lang.reflect.Method,AnnotationValue.Loaded<?>> values
protected AnnotationInvocationHandler(java.lang.Class<T> annotationType, java.util.LinkedHashMap<java.lang.reflect.Method,AnnotationValue.Loaded<?>> values)
annotationType
- The loaded annotation type.values
- A sorted list of values of this annotation.public static <S extends java.lang.annotation.Annotation> S of(java.lang.ClassLoader classLoader, java.lang.Class<S> annotationType, java.util.Map<java.lang.String,? extends AnnotationValue<?,?>> values) throws java.lang.ClassNotFoundException
S
- The type of the handled annotation.classLoader
- The class loader that should be used for loading the annotation's values.annotationType
- The annotation's type.values
- The values that the annotation contains.java.lang.ClassNotFoundException
- If the class of an instance that is contained by this annotation could not be found.private static AnnotationValue<?,?> defaultValueOf(java.lang.reflect.Method method)
method
- The method from which to attempt the extraction of a default value.private static java.lang.Class<?> asWrapper(java.lang.Class<?> type)
type
- The type to resolve.public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] argument)
invoke
in interface java.lang.reflect.InvocationHandler
protected java.lang.String toStringRepresentation()
private int hashCodeRepresentation()
private boolean equalsRepresentation(java.lang.Object self, java.lang.Object other)
self
- The annotation proxy instance.other
- The instance to be examined for equality to the represented instance.true
if the given instance is equal to the represented instance.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object