Class ReflectionUtil

java.lang.Object
org.apache.uima.fit.internal.ReflectionUtil

public final class ReflectionUtil extends Object
INTERNAL API - Utility methods to access Java annotations.
  • Method Details

    • getFields

      public static List<Field> getFields(Object aObject)
      Get all the fields for the class (and superclasses) of the passed in object
      Parameters:
      aObject - any object will do
      Returns:
      the fields for the class of the object
    • getFields

      public static List<Field> getFields(Class<?> aClass)
      Get all the fields for this class and all of its superclasses
      Parameters:
      aClass - any class will do
      Returns:
      the fields for the class and all of its superclasses
    • getField

      public static Field getField(Object aObject, String aName) throws NoSuchFieldException
      Get the given field of the passed in object from its class or the first superclass that declares it.
      Parameters:
      aObject - any object will do
      aName - the name of the field
      Returns:
      the fields for the class of the object
      Throws:
      NoSuchFieldException - if there is no such field
    • getField

      public static Field getField(Class<?> aClass, String aName) throws NoSuchFieldException
      Get the given field from the class or the first superclass that declares it.
      Parameters:
      aClass - any class will do
      aName - the field name
      Returns:
      the fields for the class of the object
      Throws:
      NoSuchFieldException - if there is no such field
    • getInheritableAnnotation

      public static <T extends Annotation> T getInheritableAnnotation(Class<T> aAnnotation, Class<?> aClass)
      Search for an annotation of the specified type starting on the given class and tracking back the inheritance hierarchy. Only parent classes are tracked back, no implemented interfaces.
      Type Parameters:
      T - the annotation type
      Parameters:
      aAnnotation - the annotation class
      aClass - the class to start searching on
      Returns:
      the annotation or null if it could not be found
    • isAnnotationPresent

      public static boolean isAnnotationPresent(AccessibleObject aObject, Class<? extends Annotation> aAnnotationClass)
      Equivalent to AccessibleObject.isAnnotationPresent(Class) but handles uimaFIT legacy annotations.
      Parameters:
      aObject - the object to analyze
      aAnnotationClass - the annotation to check for
      Returns:
      whether the annotation is present
    • isAnnotationPresent

      public static boolean isAnnotationPresent(Class<?> aObject, Class<? extends Annotation> aAnnotationClass)
      Equivalent to Class.isAnnotationPresent(Class) but handles uimaFIT legacy annotations.
      Parameters:
      aObject - the object to analyze
      aAnnotationClass - the annotation to check for
      Returns:
      whether the annotation is present
    • getAnnotation

      public static <T extends Annotation> T getAnnotation(AccessibleObject aObject, Class<T> aAnnotationClass)
      Equivalent to AccessibleObject.getAnnotation(Class) but handles uimaFIT legacy annotations.
      Type Parameters:
      T - the annotation type
      Parameters:
      aObject - the object to analyze
      aAnnotationClass - the annotation to check for
      Returns:
      the annotation
    • getAnnotation

      public static <T extends Annotation> T getAnnotation(Class<?> aObject, Class<T> aAnnotationClass)
      Equivalent to Class.getAnnotation(Class) but handles uimaFIT legacy annotations.
      Type Parameters:
      T - the annotation type
      Parameters:
      aObject - the object to analyze
      aAnnotationClass - the annotation to check for
      Returns:
      the annotation