Interface Resolver

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractPathResolver, FolderResolver, JarResolver, JModResolver

public interface Resolver extends Closeable
A Resolver, capable of loading the raw bytes for a given Class or Resource.

Created by covers1624 on 8/4/21.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
     
    static Resolver
    Finds a resolver for the given file.
    net.covers1624.quack.collection.FastStream<String>
    Gets all the classes available from this Resolver.
    net.covers1624.quack.collection.FastStream<String>
    Gets all the non-class files available from this Resolver.
    default byte @Nullable []
    Gets the bytes for a given class.
    byte @Nullable []
    Gets the bytes for a given resource.
    default boolean
    Checks if this resolver is capable of resolving the given class name.
    boolean
    Checks if this resolver is capable of resolving the given resource.
  • Method Details

    • getAllClasses

      net.covers1624.quack.collection.FastStream<String> getAllClasses() throws IOException
      Gets all the classes available from this Resolver.
      Returns:
      The classes.
      Throws:
      IOException
    • getAllResources

      net.covers1624.quack.collection.FastStream<String> getAllResources() throws IOException
      Gets all the non-class files available from this Resolver.
      Returns:
      The non-class files.
      Throws:
      IOException
    • getClassBytes

      default byte @Nullable [] getClassBytes(String name) throws IOException
      Gets the bytes for a given class.
      Parameters:
      name - The class name.
      Returns:
      The Class bytes, or literal null if no bytes were found.
      Throws:
      IOException - If an error occurred whilst reading a file.
      See Also:
    • hasClass

      default boolean hasClass(String name)
      Checks if this resolver is capable of resolving the given class name.
      Parameters:
      name - The class name.
      Returns:
      If the resolver can resolve this class.
    • getResource

      byte @Nullable [] getResource(String name) throws IOException
      Gets the bytes for a given resource.
      Parameters:
      name - The name of the input.
      Returns:
      The bytes of the resource or literal null if no bytes were found.
      Throws:
      IOException - If an error occurred whilst reading a file.
      See Also:
    • hasResource

      boolean hasResource(String name)
      Checks if this resolver is capable of resolving the given resource.
      Parameters:
      name - The resource name.
      Returns:
      If the resolver can resolve this class.
    • close

      default void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • findResolver

      static Resolver findResolver(Path path)
      Finds a resolver for the given file.
      Parameters:
      path - The file path.
      Returns:
      The Resolver.
      Throws:
      IllegalArgumentException - Thrown if a resolver was not found for a given type.