Class ClassLoader.Builder

java.lang.Object
org.skriptlang.skript.util.ClassLoader.Builder
Enclosing class:
ClassLoader

public static final class ClassLoader.Builder extends Object
A builder for constructing a ClassLoader.
  • Method Details

    • basePackage

      @Contract("_ -> this") public ClassLoader.Builder basePackage(String 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

      @Contract("_ -> this") public ClassLoader.Builder addSubPackage(String subPackage)
      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

      @Contract("_ -> this") public ClassLoader.Builder addSubPackages(String... subPackages)
      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

      @Contract("_ -> this") public ClassLoader.Builder addSubPackages(Collection<String> subPackages)
      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

      @Contract("_ -> this") public ClassLoader.Builder initialize(boolean initialize)
      Sets whether the loader will initialize found classes.
      Parameters:
      initialize - Whether classes should be initialized when found.
      Returns:
      This builder.
    • deep

      @Contract("_ -> this") public ClassLoader.Builder deep(boolean 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

      @Contract("_ -> this") public ClassLoader.Builder forEachClass(Consumer<Class<?>> 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

      @Contract("-> new") public ClassLoader build()
      Builds a new loader from the set details.
      Returns:
      A loader for loading classes through the manner outlined by this builder.