Package me.deecaad.core.file
Class JarSearcher
java.lang.Object
me.deecaad.core.file.JarSearcher
- Direct Known Subclasses:
JarInstancer,SerializerInstancer
This immutable class outlines a searcher that iterates through the files of a
JarFile.-
Constructor Summary
ConstructorsConstructorDescriptionJarSearcher(@NotNull JarFile jar) This constructor will throw anIllegalArgumentExceptionif the givenjaris null. -
Method Summary
Modifier and TypeMethodDescriptionfindAllSubclasses(@NotNull Class<T> clazz, @NotNull ClassLoader clazzLoader, @NotNull SearchMode filter)
-
Constructor Details
-
JarSearcher
This constructor will throw anIllegalArgumentExceptionif the givenjaris null.JarFileinstances can be obtained viaFileUtil.getJarFile(Plugin, File).- Parameters:
jar- The.jarfile to search.
-
-
Method Details
-
findAllSubclasses
public <T> List<Class<T>> findAllSubclasses(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull ClassLoader clazzLoader, @NotNull @NotNull SearchMode filter) Returns aListof every class that inherits from the given classclazzthat can be found in this searcher'sJarFile.This is useful if addons to a plugin create an new implementation for a feature, so the main plugin doesn't have to write a registry system for each feature. Instead, the main plugin can pull all features from registered jars.
- Type Parameters:
T- The parent class that all of these subclasses will have in common.- Parameters:
clazz- The class that the subclasses inherit from. This is generally an abstract class/interface.clazzLoader- The class that is used to load classesfilter- The filter for which serializers to use- Returns:
- A
Listof every subclass.
-