use of com.shulie.instrument.simulator.module.util.InterfaceNameRegexFilter in project LinkAgent by shulieTech.
the class ScModule method sc.
@Command(value = "sc", description = "查找类")
public CommandResponse sc(final Map<String, String> param) {
try {
final String cnPattern = getParameter(param, "class");
final String type = getParameter(param, "type");
if (StringUtils.isBlank(type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new NameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
} else if (StringUtils.equals("s", type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new SuperNameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
} else if (StringUtils.equals("i", type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new InterfaceNameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
}
return CommandResponse.failure("Unsupported type value:" + type);
} catch (Throwable e) {
return CommandResponse.failure(e);
}
}
Aggregations