JavaReflectionUtil.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:Reer 作者:
private static <A extends Annotation> A getAnnotation(Class<?> type, Class<A> annotationType, boolean checkType) {
    A annotation;
    if (checkType) {
        annotation = type.getAnnotation(annotationType);
        if (annotation != null) {
            return annotation;
        }
    }

    if (annotationType.getAnnotation(Inherited.class) != null) {
        for (Class<?> anInterface : type.getInterfaces()) {
            annotation = getAnnotation(anInterface, annotationType, true);
            if (annotation != null) {
                return annotation;
            }
        }
    }

    if (type.isInterface() || type.equals(Object.class)) {
        return null;
    } else {
        return getAnnotation(type.getSuperclass(), annotationType, false);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号