Package org.skriptlang.skript.util
Class ClassLoader.Builder
java.lang.Object
org.skriptlang.skript.util.ClassLoader.Builder
- Enclosing class:
ClassLoader
A builder for constructing a
ClassLoader
.-
Method Summary
Modifier and TypeMethodDescriptionaddSubPackage
(String subPackage) Adds a subpackage the loader should start loading classes from.addSubPackages
(String... subPackages) Adds subpackages the loader should start loading classes from.addSubPackages
(Collection<String> subPackages) Adds subpackages the loader should start loading classes from.basePackage
(String basePackage) Sets the package the loader should start loading classes from.build()
Builds a new loader from the set details.deep
(boolean deep) Sets whether the loader will perform a deep search.forEachClass
(Consumer<Class<?>> forEachClass) Sets a consumer to be run for each found class.initialize
(boolean initialize) Sets whether the loader will initialize found classes.
-
Method Details
-
basePackage
Sets the package the loader should start loading classes from. This is required.- Parameters:
basePackage
- A string representing package to start loading classes from.- Returns:
- This builder.
-
addSubPackage
Adds a subpackage the loader should start loading classes from. This is useful for when you may want to load from some, but not all, of the subpackages of the base package.- Parameters:
subPackage
- A string representing a subpackage to load from.- Returns:
- This builder.
- See Also:
-
addSubPackages
Adds subpackages the loader should start loading classes from. This is useful for when you may want to load from some, but not all, of the subpackages of the base package.- Parameters:
subPackages
- Strings representing subpackages to load from.- Returns:
- This builder.
- See Also:
-
addSubPackages
Adds subpackages the loader should start loading classes from. This is useful for when you may want to load from some, but not all, of the subpackages of the base package.- Parameters:
subPackages
- Strings representing subpackages to load from.- Returns:
- This builder.
- See Also:
-
initialize
Sets whether the loader will initialize found classes.- Parameters:
initialize
- Whether classes should be initialized when found.- Returns:
- This builder.
-
deep
Sets whether the loader will perform a deep search.- Parameters:
deep
- Whether subpackages of the provided base package (or subpackages) should be searched.- Returns:
- This builder.
-
forEachClass
Sets a consumer to be run for each found class.- Parameters:
forEachClass
- A consumer to run for each found class.- Returns:
- This builder.
-
build
Builds a new loader from the set details.- Returns:
- A loader for loading classes through the manner outlined by this builder.
-