Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.annotation.Annotation;

public class Main {
    public static <A extends Annotation> A getAnnotationFromHierarchy(final Class<?> clazz,
            final Class<A> annotation) {
        Class<?> currentClass = clazz;
        A annotationInstance;
        do {
            annotationInstance = currentClass.getAnnotation(annotation);
            currentClass = currentClass.getSuperclass();
        } while (annotationInstance == null && currentClass != Object.class);
        return annotationInstance;
    }
}