package cd.casic.plugin.utils;

import java.lang.annotation.Annotation;

public class AnnotationUtils {
    @SafeVarargs
    public static boolean hasAnnotations(Class<?> clazz,
                                         boolean allRequired,
                                         Class<? extends Annotation>... annotations) {
        if (clazz == null) return false;
        if (annotations == null) return false;
        for (Class<? extends Annotation> annotation : annotations) {
            if (clazz.isAnnotationPresent(annotation)) {
                if (!allRequired) return true;
            } else {
                if (allRequired) return false;
            }
        }
        return allRequired;
    }
}
