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>annotationTypeThe annotation type class has to be proxed.private static intMEMBER_NAME_MULTIPLICATORThe multiplicator required in the hash code calculation.private java.util.Map<java.lang.String,AnnotationProperty>propertiesThe annotation properties registry.private AproxedAnnotationThe proxed annotation.
-
Constructor Summary
Constructors Modifier Constructor Description privateAnnotationProxy(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()booleanequals(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.ObjectgetProperty(java.lang.String name)Returns the property value, given the name, if present.AgetProxedAnnotation()Returns the proxed annotation.inthashCode()java.lang.Objectinvoke(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.voidsetProperty(java.lang.String name, java.lang.Object value)Set a property value.java.lang.StringtoString()
-
-
-
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:
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
-
getProxedAnnotation
public A getProxedAnnotation()
Returns the proxed annotation.- Returns:
- the proxed annotation.
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.lang.annotation.Annotation- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.lang.annotation.Annotation- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.annotation.Annotation- Overrides:
toStringin classjava.lang.Object
-
-