All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.starblues.utils.AnnotationsUtils Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.gitee.starblues.utils;

import java.lang.annotation.Annotation;

/**
 * 注解工具
 *
 * @author zhangzhuo
 * @version 1.0
 */
public class AnnotationsUtils {

    private AnnotationsUtils(){

    }


    /**
     * 存在注解判断
     * @param aClass 类
     * @param isAllMatch 是否匹配全部注解
     * @param annotationClasses 注解类
     * @return boolean
     */
    public static boolean haveAnnotations(Class aClass, boolean isAllMatch,
                                          Class ...annotationClasses){
        if(aClass == null){
            return false;
        }
        if(annotationClasses == null){
            return false;
        }
        for (Class annotationClass : annotationClasses) {
            Annotation annotation = aClass.getAnnotation(annotationClass);
            if(isAllMatch){
                if(annotation == null){
                    return false;
                }
            } else {
                if(annotation != null){
                    return true;
                }
            }
        }
        if(isAllMatch){
            return true;
        } else {
            return false;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy