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

com.atlassian.bootgraph.api.AnnotationUtil.kt Maven / Gradle / Ivy

There is a newer version: TEST-0.0.15
Show newest version
package com.atlassian.bootgraph.api

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition
import org.springframework.beans.factory.config.BeanDefinition

fun  isBeanAnnotated(bean: Any, beanDefinition: BeanDefinition, annotationClazz: Class): Boolean {
    return isBeanAnnotatedDirectly(bean, annotationClazz) || isFactoryMethodAnnotated(beanDefinition, annotationClazz)
}

private fun  isBeanAnnotatedDirectly(bean: Any, annotationClazz: Class): Boolean {
    return bean.javaClass.isAnnotationPresent(annotationClazz)
}

private fun  isFactoryMethodAnnotated(beanDefinition: BeanDefinition, annotationClazz: Class): Boolean {
    if (beanDefinition !is AnnotatedBeanDefinition) {
        return false
    }

    return beanDefinition.factoryMethodMetadata?.isAnnotated(annotationClazz.name) ?: false
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy