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

ioinformarics.oss.jackson.module.jsonld.util.AnnotationsUtils Maven / Gradle / Ivy

The newest version!
package ioinformarics.oss.jackson.module.jsonld.util;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Alexander De Leon ([email protected])
 */
public abstract class AnnotationsUtils {

    public static boolean isAnnotationPresent(Class type, Class annotationType) {
        return isAnnotationPresent(type, annotationType, new ArrayList<>());
    }

    protected static boolean isAnnotationPresent(Class type, Class annotationType, List> ignore) {
        if(type.isAnnotationPresent(annotationType)) {
            return true;
        }
        if(type.getAnnotations().length == 0) {
            return false;
        }
        for(Annotation a : type.getAnnotations()) {
            if(!ignore.contains(a.annotationType())) {
                ignore.add(type);
                if(isAnnotationPresent(a.annotationType(), annotationType, ignore)) {
                    return true;
                }
            }
        }
        return false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy