1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-23 07:50:09 -08:00

Comment class finder.

This commit is contained in:
Danila Fedorin 2017-07-28 14:32:27 -07:00
parent 0592200961
commit 6aa9225eee

View File

@ -17,10 +17,24 @@ import java.util.stream.Collectors;
*/
public class ClassFinder {
/**
* Loads all the plugin classes from the given plugin folder.
* @param filePath the path for the plugin folder.
* @return the list of all loaded classes.
* @throws IOException thrown if an error occurred scanning the plugin folder.
* @throws ClassNotFoundException thrown if the class listed in the file doesn't get loaded.
*/
public static ArrayList<Class<?>> loadJars(String filePath) throws IOException, ClassNotFoundException {
return loadJars(new File(filePath));
}
/**
* Loads all the plugin classes from the given plugin folder.
* @param pluginFolderPath the folder in which to look for plugins.
* @return the list of all loaded classes.
* @throws IOException thrown if an error occurred scanning the plugin folder.
* @throws ClassNotFoundException thrown if the class listed in the file doesn't get loaded.
*/
public static ArrayList<Class<?>> loadJars(File pluginFolderPath) throws IOException, ClassNotFoundException {
ArrayList<Class<?>> toReturn = new ArrayList<>();
if(!pluginFolderPath.exists()) return toReturn;
@ -34,10 +48,13 @@ public class ClassFinder {
return toReturn;
}
public static ArrayList<Class<?>> loadJar(String path) throws IOException, ClassNotFoundException {
return loadJar(new File(path));
}
/**
* Loads the classes from a single path, given by the file.
* @param jarLocation the location of the jar to load.
* @return the list of loaded classes loaded from the jar.
* @throws IOException thrown if there was an error reading the file
* @throws ClassNotFoundException thrown if the class could not be loaded.
*/
public static ArrayList<Class<?>> loadJar(File jarLocation) throws IOException, ClassNotFoundException {
ArrayList<Class<?>> loadedClasses = new ArrayList<>();
String path = jarLocation.getPath();