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

com.qa.framework.classfinder.ClassFinder Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version
package com.qa.framework.classfinder;

import com.qa.framework.InstanceFactory;
import com.qa.framework.config.PropConfig;

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

/**
 * 根据条件获取相关类
 */
public class ClassFinder {

    /**
     * 获取 ClassScanner
     */
    private static final ClassScanner classScanner = InstanceFactory.getClassScanner();
    /**
     * 获取基础包名
     */
    private static String basePackage = "";

    static {
        if (PropConfig.getBasePackage() == null) {
            basePackage = "";
        } else {
            basePackage = PropConfig.getBasePackage();
        }

    }

    /**
     * 获取基础包名中的所有类
     *
     * @return the class list
     */
    public static List> getClassList() {
        return classScanner.getClassList(basePackage);
    }

    /**
     * 获取基础包名中指定父类或接口的相关类
     *
     * @param superClass the super class
     * @return the class list by super
     */
    public static List> getClassListBySuper(Class superClass) {
        return classScanner.getClassListBySuper(basePackage, superClass);
    }

    /**
     * 获取基础包名中指定注解的相关类
     *
     * @param annotationClass the annotation class
     * @return the class list by annotation
     */
    public static List> getClassListByAnnotation(Class annotationClass) {
        return classScanner.getClassListByAnnotation(basePackage, annotationClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy