Class Decompiler.Builder

java.lang.Object
net.covers1624.coffeegrinder.Decompiler.Builder
Enclosing class:
Decompiler

public static class Decompiler.Builder extends Object
A builder for configuring a Decompilation operation.
  • Method Details

    • setCurrentJvmReference

      public Decompiler.Builder setCurrentJvmReference()
      Set the reference JRE to the current running JVM.

      It is usually recommended that you specify an explicit JRE for the exact target your input was compiled with for best results.

      Will discard and close any previously set jre reference resolvers.

      Returns:
      The same builder.
    • setJreReference

      public Decompiler.Builder setJreReference(Path jreReference)
      Set the reference JRE to the given java executable or home path.

      Will discard and close any previously set jre reference resolvers.

      Parameters:
      jreReference - The reference path.
      Returns:
      The same builder.
    • setJreReference

      public Decompiler.Builder setJreReference(@WillCloseWhenClosed Iterable<? extends Resolver> resolvers)
      Set the reference JRE to the given resolvers.

      Will discard and close any previously set jre reference resolvers.

      Takes resource ownership of the supplied Resolver instances, these will be closed on discard() or via Decompiler.close().

      Parameters:
      resolvers - The resolvers.
      Returns:
      The same builder.
    • withReferencePaths

      public Decompiler.Builder withReferencePaths(Path... libraries)
      Add all the given paths as additional reference libraries.
      Parameters:
      libraries - The libraries.
      Returns:
      The same builder.
    • withReferencePaths

      public Decompiler.Builder withReferencePaths(Iterable<Path> libraries)
      Add all the given paths as additional reference libraries.
      Parameters:
      libraries - The libraries.
      Returns:
      The same builder.
    • withReferenceLibraries

      public Decompiler.Builder withReferenceLibraries(@WillCloseWhenClosed Iterable<? extends Resolver> resolvers)
      Add all the given Resolvers as additional reference libraries.

      Takes resource ownership of the supplied Resolver instances, these will be closed on discard() or via Decompiler.close().

      Parameters:
      resolvers - The resolvers to add.
      Returns:
      The same builder.
    • setInput

      public Decompiler.Builder setInput(Path input)
      Set the input path to decompile.
      Parameters:
      input - The input.
      Returns:
      The same builder.
    • setInput

      public Decompiler.Builder setInput(@WillCloseWhenClosed Resolver input)
      Set the input Resolver to decompile.

      Takes resource ownership of the supplied Resolver instance, it will be closed on discard() or via Decompiler.close().

      Parameters:
      input - The input.
      Returns:
      The same builder.
    • withSettings

      public Decompiler.Builder withSettings(Consumer<DecompilerSettings> cons)
      Configure any decompiler settings.
      Parameters:
      cons - The configuration action.
      Returns:
      The same builder.
    • setThreads

      public Decompiler.Builder setThreads(int threads)
      Specify the number of threads to use whilst decompiling.

      If not specified defaults to the number of available cores minus one.

      Parameters:
      threads - The number of threads to use.
      Returns:
      The same builder.
    • setListener

      public Decompiler.Builder setListener(DecompilerListener listener)
      Set the listener for decompiler events.
      Parameters:
      listener - The listener.
      Returns:
      The same builder.
    • build

      public Decompiler build(@Nullable @Nullable OutputSink resourceSink, OutputSink outputSink)
      Finish configuring the Decompilation operation, and return the Decompiler for use.
      Parameters:
      resourceSink - The OutputSink to place resource files into.
      outputSink - The OutputSink to place decompilation results into.
      Returns:
      The configured decompiler.
    • discard

      public void discard() throws IOException
      Discard all resources retained by the builder without building a Decompiler.
      Throws:
      IOException