package io.github.jordandoyle.helpers.reflection;
import io.github.jordandoyle.helpers.classloader.Loader;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
public class Package {
public static List<Class> getClassesInPackage(java.lang.Package p, ClassLoader classLoader)
throws Exception {
return getClassesInPackage(p.getName(), classLoader);
}
public static List<Class> getClassesInPackage(java.lang.Package p)
throws Exception {
return getClassesInPackage(p.getName());
}
public static List<Class> getClassesInPackage(String name) throws Exception {
return getClassesInPackage(name, ClassLoader.getSystemClassLoader());
}
public static List<Class> getClassesInPackage(String name, ClassLoader classLoader) throws Exception {
Vector<Class> classes = Loader.getAllClasses(classLoader);
List<Class> inPackage = new ArrayList<Class>();
for (Class c : classes) {
java.lang.Package p = c.getPackage();
if (p != null && p.getName() != null
&& p.getName().startsWith(name))
inPackage.add(c);
}
return inPackage;
}
}