com.qa.framework.classfinder.ClassFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smart-api-framework Show documentation
Show all versions of smart-api-framework Show documentation
Support web service api automaton test based on testng and httpclient
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 extends Annotation> annotationClass) {
return classScanner.getClassListByAnnotation(basePackage, annotationClass);
}
}