Package jnr.ffi.util

Class AnnotationProxy<A extends Annotation>

java.lang.Object
jnr.ffi.util.AnnotationProxy<A>
Type Parameters:
A - The annotation type has to be proxed.
All Implemented Interfaces:
Annotation, InvocationHandler

public final class AnnotationProxy<A extends Annotation> extends Object implements Annotation, InvocationHandler
Version:
$Id$
  • Field Details

    • MEMBER_NAME_MULTIPLICATOR

      private static final int MEMBER_NAME_MULTIPLICATOR
      The multiplicator required in the hash code calculation.
      See Also:
    • annotationType

      private final Class<A extends Annotation> annotationType
      The annotation type class has to be proxed.
    • properties

      private final Map<String,AnnotationProperty> properties
      The annotation properties registry.
    • proxedAnnotation

      private final A extends Annotation proxedAnnotation
      The proxed annotation.
  • Constructor Details

    • AnnotationProxy

      private AnnotationProxy(Class<A> annotationType)
      Build a new proxy annotation given the annotation type.
      Parameters:
      annotationType - the annotation type class has to be proxed.
  • Method Details

    • newProxy

      public static <A extends Annotation> AnnotationProxy<A> newProxy(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(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 Annotation> Method[] getDeclaredMethods(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(String name, Object value)
      Set a property value.
      Parameters:
      name - the property name.
      value - the property value.
    • getProperty

      public Object getProperty(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 Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable
    • annotationType

      public Class<? extends Annotation> annotationType()
      Specified by:
      annotationType in interface Annotation
    • getProxedAnnotation

      public A getProxedAnnotation()
      Returns the proxed annotation.
      Returns:
      the proxed annotation.
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Annotation
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Annotation
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Specified by:
      toString in interface Annotation
      Overrides:
      toString in class Object