Package jnr.ffi.util
Class AnnotationProxy<A extends java.lang.annotation.Annotation>
- java.lang.Object
-
- jnr.ffi.util.AnnotationProxy<A>
-
- Type Parameters:
A
- The annotation type has to be proxed.
- All Implemented Interfaces:
java.lang.annotation.Annotation
,java.lang.reflect.InvocationHandler
public final class AnnotationProxy<A extends java.lang.annotation.Annotation> extends java.lang.Object implements java.lang.annotation.Annotation, java.lang.reflect.InvocationHandler
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<A>
annotationType
The annotation type class has to be proxed.private static int
MEMBER_NAME_MULTIPLICATOR
The multiplicator required in the hash code calculation.private java.util.Map<java.lang.String,AnnotationProperty>
properties
The annotation properties registry.private A
proxedAnnotation
The proxed annotation.
-
Constructor Summary
Constructors Modifier Constructor Description private
AnnotationProxy(java.lang.Class<A> annotationType)
Build a new proxy annotation given the annotation type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<? extends java.lang.annotation.Annotation>
annotationType()
boolean
equals(java.lang.Object obj)
private static AnnotationProxy<?>
getAnnotationProxy(java.lang.Object obj)
Retrieves the annotation proxy, if any, given the annotation.private static <A extends java.lang.annotation.Annotation>
java.lang.reflect.Method[]getDeclaredMethods(java.lang.Class<A> annotationType)
Access to the declared methods of an annotation, given the type.java.lang.Object
getProperty(java.lang.String name)
Returns the property value, given the name, if present.A
getProxedAnnotation()
Returns the proxed annotation.int
hashCode()
java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
static <A extends java.lang.annotation.Annotation>
AnnotationProxy<A>newProxy(java.lang.Class<A> annotationType)
Creates a new annotation proxy.void
setProperty(java.lang.String name, java.lang.Object value)
Set a property value.java.lang.String
toString()
-
-
-
Field Detail
-
MEMBER_NAME_MULTIPLICATOR
private static final int MEMBER_NAME_MULTIPLICATOR
The multiplicator required in the hash code calculation.- See Also:
- Constant Field Values
-
annotationType
private final java.lang.Class<A extends java.lang.annotation.Annotation> annotationType
The annotation type class has to be proxed.
-
properties
private final java.util.Map<java.lang.String,AnnotationProperty> properties
The annotation properties registry.
-
proxedAnnotation
private final A extends java.lang.annotation.Annotation proxedAnnotation
The proxed annotation.
-
-
Constructor Detail
-
AnnotationProxy
private AnnotationProxy(java.lang.Class<A> annotationType)
Build a new proxy annotation given the annotation type.- Parameters:
annotationType
- the annotation type class has to be proxed.
-
-
Method Detail
-
newProxy
public static <A extends java.lang.annotation.Annotation> AnnotationProxy<A> newProxy(java.lang.Class<A> annotationType)
Creates a new annotation proxy.- Type Parameters:
A
- the annotation type has to be proxed.- Parameters:
annotationType
- the annotation type class has to be proxed.- Returns:
- a new annotation proxy.
-
getAnnotationProxy
private static AnnotationProxy<?> getAnnotationProxy(java.lang.Object obj)
Retrieves the annotation proxy, if any, given the annotation.- Parameters:
obj
- the annotation.- Returns:
- the annotation proxy, if any, given the annotation.
-
getDeclaredMethods
private static <A extends java.lang.annotation.Annotation> java.lang.reflect.Method[] getDeclaredMethods(java.lang.Class<A> annotationType)
Access to the declared methods of an annotation, given the type.- Type Parameters:
A
- the annotation type.- Parameters:
annotationType
- the annotation type class.- Returns:
- the declared methods of an annotation, given the type.
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)
Set a property value.- Parameters:
name
- the property name.value
- the property value.
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
Returns the property value, given the name, if present.- Parameters:
name
- the property name.- Returns:
- the property value, given the name, if present.
-
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
-
getProxedAnnotation
public A getProxedAnnotation()
Returns the proxed annotation.- Returns:
- the proxed annotation.
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.lang.annotation.Annotation
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.lang.annotation.Annotation
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.annotation.Annotation
- Overrides:
toString
in classjava.lang.Object
-
-