Class ExpansionClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public final class ExpansionClassLoader extends URLClassLoader
The class loader of the expansion
  • Constructor Details

    • ExpansionClassLoader

      public ExpansionClassLoader(@NotNull @NotNull ExpansionManager manager, @NotNull @NotNull File file, @NotNull @NotNull ExpansionDescription description, @NotNull @NotNull ClassLoader parent) throws MalformedURLException
      Create a new class loader
      Parameters:
      manager - the expansion manager
      file - the expansion jar
      description - the description for the expansion
      parent - the parent class loader
      Throws:
      MalformedURLException - if it cannot convert the file to its related URL
  • Method Details

    • getExpansionOptional

      public Optional<Expansion> getExpansionOptional()
      Get the expansion if it's initialized
      Returns:
      the optional expansion
    • getExpansion

      @NotNull public @NotNull Expansion getExpansion()
      Get the expansion
      Returns:
      the expansion
      Throws:
      IllegalStateException - if the expansion is not found or not initialized
    • getFile

      @NotNull public @NotNull File getFile()
      Get the expansion jar
      Returns:
      the expansion jar
    • getManager

      @NotNull public @NotNull ExpansionManager getManager()
      Get the expansion manager
      Returns:
      the expansion manager
    • getDescription

      @NotNull public @NotNull ExpansionDescription getDescription()
      Get the expansion's description
      Returns:
      the description
    • getState

      @NotNull public @NotNull ExpansionState getState()
      Get the state of the expansion
      Returns:
      the state
    • getThrowable

      @Nullable public @Nullable Throwable getThrowable()
      Get the throwable if the expansion is in ExpansionState.ERROR
      Returns:
      the throwable
    • setThrowable

      public void setThrowable(@NotNull @NotNull Throwable throwable)
      Set the throwable if the expansion is in ExpansionState.ERROR
      Parameters:
      throwable - the throwable
    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      Overrides:
      loadClass in class ClassLoader
      Throws:
      ClassNotFoundException