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

site.sorghum.anno._common.AnnoBeanUtils Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package site.sorghum.anno._common;

import site.sorghum.anno._metadata.MetadataManager;

import java.util.ArrayList;
import java.util.List;

/**
 * @author songyinyin
 * @since 2023/7/30 15:45
 */
public class AnnoBeanUtils {

    private static AnnoBean annoBean;

    public static void setBean(AnnoBean annoBean) {
        AnnoBeanUtils.annoBean = annoBean;
    }

    public static  T getBean(String name) {
        return annoBean.getBean(name);
    }

    public static  T getBean(Class type) {
        return annoBean.getBean(type);
    }

    public static  List getBeansOfType(Class type) {
        List beans = annoBean.getBeansOfType(type);
        // springboot 中,获取到的集合是不可更改的,转成 ArrayList,后续可以进行排序等操作
        if (beans.getClass().getName().startsWith("java.util.ImmutableCollections")) {
            return new ArrayList<>(beans);
        } else {
            return beans;
        }
    }

    public static MetadataManager metadataManager() {
        return annoBean.getBean(MetadataManager.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy