java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.TypeSolverBuilder

public class TypeSolverBuilder extends Object
TypeSolverBuilder was created with the objective of simplifying the process of creating new type solved. Instead of invoking the constructor directly, the user can build it using the builder pattern.

Example 1: Solve JRE types:

     new TypeSolverBuilder()
          .withCurrentJRE()
          .build()
 

Example 2: Solve JRE and types defined in foo.jar:

     new TypeSolverBuilder()
          .withCurrentJRE()
          .withJAR("foo.jar")
          .build()
 
  • Field Details

  • Constructor Details

    • TypeSolverBuilder

      public TypeSolverBuilder()
  • Method Details

    • with

      public TypeSolverBuilder with(@NonNull TypeSolver typeSolver)
      Append a costum type solver to the build.
      Parameters:
      typeSolver - The type solver to be added.
      Returns:
      the current builder.
    • withCurrentJRE

      public TypeSolverBuilder withCurrentJRE()
      Allow the type solver to resolve types that are defined in the current Java Runtime Environment (JRE).

      Some examples of those types are:

      • java.lang.Object
      • java.lang.String
      • java.lang.Math
      • ...
      Returns:
      the current builder.
      See Also:
    • withCurrentClassloader

      public TypeSolverBuilder withCurrentClassloader()
      Allow the type solver to resolve types that are defined in the current ClassLoader.

      Some examples of those types are:

      • java.lang.Object
      • java.lang.String
      • java.lang.Math
      • com.github.javaparser.ast.Node
      • com.github.javaparser.symbolsolver.resolution.typesolvers.TypeSolverBuilder
      • ...
      Returns:
      the current builder.
      See Also:
    • withJAR

      public TypeSolverBuilder withJAR(@NonNull Path pathToJar) throws IOException
      Allow the type solver to resolve types that are defined in a JAR file.
      Parameters:
      pathToJar - The path to the jar file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar.
      See Also:
    • withJAR

      public TypeSolverBuilder withJAR(@NonNull File pathToJar) throws IOException
      Allow the type solver to resolve types that are defined in a JAR file.
      Parameters:
      pathToJar - The jar file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar.
      See Also:
    • withJAR

      public TypeSolverBuilder withJAR(@NonNull String pathToJar) throws IOException
      Allow the type solver to resolve types that are defined in a JAR file.
      Parameters:
      pathToJar - The path to the jar file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar.
      See Also:
    • withAAR

      public TypeSolverBuilder withAAR(@NonNull Path pathToAar) throws IOException
      Allow the type solver to resolve types that are defined in a AAR file.
      Parameters:
      pathToAar - The path to the AAR file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the AAR.
      See Also:
    • withAAR

      public TypeSolverBuilder withAAR(@NonNull File pathToAar) throws IOException
      Allow the type solver to resolve types that are defined in a AAR file.
      Parameters:
      pathToAar - The AAR file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the AAR.
      See Also:
    • withAAR

      public TypeSolverBuilder withAAR(@NonNull String pathToAar) throws IOException
      Allow the type solver to resolve types that are defined in a AAR file.
      Parameters:
      pathToAar - The path to the AAR file.
      Returns:
      the current builder.
      Throws:
      IOException - If an I/O exception occurs while reading the AAR.
      See Also:
    • withSourceCode

      public TypeSolverBuilder withSourceCode(@NonNull Path pathToSourceCode)
      Allow the type solver to resolve types using external source code.
      Parameters:
      pathToSourceCode - The path to the source code.
      Returns:
      the current builder.
      See Also:
    • withSourceCode

      public TypeSolverBuilder withSourceCode(@NonNull File pathToSourceCode)
      Allow the type solver to resolve types using external source code.
      Parameters:
      pathToSourceCode - The source code file.
      Returns:
      the current builder.
      See Also:
    • withSourceCode

      public TypeSolverBuilder withSourceCode(@NonNull String pathToSourceCode)
      Allow the type solver to resolve types using external source code.
      Parameters:
      pathToSourceCode - The path to the source code.
      Returns:
      the current builder.
      See Also:
    • withClassLoader

      public TypeSolverBuilder withClassLoader(@NonNull ClassLoader classLoader)
      Allow the type solver to resolve types using the provided ClassLoader.
      Parameters:
      classLoader - The class loader to be registered.
      Returns:
      the current builder.
      See Also:
    • build

      public TypeSolver build()
      Convert the current build into a valid TypeSolver.
      Returns:
      The type solver with the requested configuration.
      Throws:
      IllegalStateException - if no build configuration is provided.