Package org.apache.uima.fit.internal
Class ReflectionUtil
java.lang.Object
org.apache.uima.fit.internal.ReflectionUtil
INTERNAL API - Utility methods to access Java annotations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Annotation>
TgetAnnotation(Class<?> aObject, Class<T> aAnnotationClass) Equivalent toClass.getAnnotation(Class)but handles uimaFIT legacy annotations.static <T extends Annotation>
TgetAnnotation(AccessibleObject aObject, Class<T> aAnnotationClass) Equivalent toAccessibleObject.getAnnotation(Class)but handles uimaFIT legacy annotations.static FieldGet the given field from the class or the first superclass that declares it.static FieldGet the given field of the passed in object from its class or the first superclass that declares it.Get all the fields for this class and all of its superclassesGet all the fields for the class (and superclasses) of the passed in objectstatic <T extends Annotation>
TgetInheritableAnnotation(Class<T> aAnnotation, Class<?> aClass) Search for an annotation of the specified type starting on the given class and tracking back the inheritance hierarchy.static booleanisAnnotationPresent(Class<?> aObject, Class<? extends Annotation> aAnnotationClass) Equivalent toClass.isAnnotationPresent(Class)but handles uimaFIT legacy annotations.static booleanisAnnotationPresent(AccessibleObject aObject, Class<? extends Annotation> aAnnotationClass) Equivalent toAccessibleObject.isAnnotationPresent(Class)but handles uimaFIT legacy annotations.
-
Method Details
-
getFields
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
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
Get the given field of the passed in object from its class or the first superclass that declares it.- Parameters:
aObject- any object will doaName- the name of the field- Returns:
- the fields for the class of the object
- Throws:
NoSuchFieldException- if there is no such field
-
getField
Get the given field from the class or the first superclass that declares it.- Parameters:
aClass- any class will doaName- 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 classaClass- the class to start searching on- Returns:
- the annotation or
nullif it could not be found
-
isAnnotationPresent
public static boolean isAnnotationPresent(AccessibleObject aObject, Class<? extends Annotation> aAnnotationClass) Equivalent toAccessibleObject.isAnnotationPresent(Class)but handles uimaFIT legacy annotations.- Parameters:
aObject- the object to analyzeaAnnotationClass- the annotation to check for- Returns:
- whether the annotation is present
-
isAnnotationPresent
public static boolean isAnnotationPresent(Class<?> aObject, Class<? extends Annotation> aAnnotationClass) Equivalent toClass.isAnnotationPresent(Class)but handles uimaFIT legacy annotations.- Parameters:
aObject- the object to analyzeaAnnotationClass- 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 toAccessibleObject.getAnnotation(Class)but handles uimaFIT legacy annotations.- Type Parameters:
T- the annotation type- Parameters:
aObject- the object to analyzeaAnnotationClass- the annotation to check for- Returns:
- the annotation
-
getAnnotation
Equivalent toClass.getAnnotation(Class)but handles uimaFIT legacy annotations.- Type Parameters:
T- the annotation type- Parameters:
aObject- the object to analyzeaAnnotationClass- the annotation to check for- Returns:
- the annotation
-