Java Utililty Methods Reflection Annotation

List of utility methods to do Reflection Annotation

Description

The list of methods to do Reflection Annotation are organized into topic(s).

Method

AgetAnnotation(Method method, Class annotationType)
get Annotation
A ann = method.getAnnotation(annotationType);
if (ann == null) {
    for (Annotation metaAnn : method.getAnnotations()) {
        ann = metaAnn.annotationType().getAnnotation(annotationType);
        if (ann != null) {
            break;
return ann;
TgetAnnotation(Method method, Class annotationClass)
Extract the annotation from the method or the declaring class.
T t = method.getAnnotation(annotationClass);
if (t == null) {
    t = getAnnotation(method.getDeclaringClass(), annotationClass);
return t;
TgetAnnotation(Method method, Class annotationClass)
get Annotation
T t = getAnnotation(method, annotationClass, annotationClass.isAnnotationPresent(Inherited.class));
return t;
TgetAnnotation(Method method, Class type)
Returns the first Annotation of the given type defined on the given Method .
for (Annotation a : getAnnotations(method)) {
    if (type.isInstance(a)) {
        return type.cast(a);
return null;
AgetAnnotation(Object bean, final Class annotation)
get Annotation
if (bean == null) {
    return null;
return getAnnotation(bean.getClass(), annotation);
TgetAnnotation(Object context, Class annotation)

Takes the target IckleActivity and finds the given annotation (if any).

Class<?> contextClass = context.getClass();
if (contextClass.isAnnotationPresent(annotation)) {
    return contextClass.getAnnotation(annotation);
} else {
    return null;
AgetAnnotation(Object instance, Class type)
Gets the annotation from the given instance.
return instance.getClass().getAnnotation(type);
AnnotationgetAnnotation(Object obj, Class annClass)
get Annotation
return getAnnotation(obj.getClass(), annClass);
AgetAnnotation(Object obj, Class acl)
get Annotation
return getAnnotation(obj.getClass(), acl);
AgetAnnotation(Object obj, Class annotation)
get Annotation
Objects.requireNonNull(obj);
return obj.getClass().getDeclaredAnnotation(annotation);