Class TypeSolverBuilder
java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.TypeSolverBuilder
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Convert the current build into a validTypeSolver
.with
(@NonNull TypeSolver typeSolver) Append a costum type solver to the build.Allow the type solver to resolve types that are defined in a AAR file.Allow the type solver to resolve types that are defined in a AAR file.Allow the type solver to resolve types that are defined in a AAR file.withClassLoader
(@NonNull ClassLoader classLoader) Allow the type solver to resolve types using the providedClassLoader
.Allow the type solver to resolve types that are defined in the currentClassLoader
.Allow the type solver to resolve types that are defined in the current Java Runtime Environment (JRE).Allow the type solver to resolve types that are defined in a JAR file.Allow the type solver to resolve types that are defined in a JAR file.Allow the type solver to resolve types that are defined in a JAR file.withSourceCode
(@NonNull File pathToSourceCode) Allow the type solver to resolve types using external source code.withSourceCode
(@NonNull String pathToSourceCode) Allow the type solver to resolve types using external source code.withSourceCode
(@NonNull Path pathToSourceCode) Allow the type solver to resolve types using external source code.
-
Field Details
-
typeSolvers
-
-
Constructor Details
-
TypeSolverBuilder
public TypeSolverBuilder()
-
-
Method Details
-
with
Append a costum type solver to the build.- Parameters:
typeSolver
- The type solver to be added.- Returns:
- the current builder.
-
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
Allow the type solver to resolve types that are defined in the currentClassLoader
. 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
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
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
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
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
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
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
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
Allow the type solver to resolve types using external source code.- Parameters:
pathToSourceCode
- The source code file.- Returns:
- the current builder.
- See Also:
-
withSourceCode
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
Allow the type solver to resolve types using the providedClassLoader
.- Parameters:
classLoader
- The class loader to be registered.- Returns:
- the current builder.
- See Also:
-
build
Convert the current build into a validTypeSolver
.- Returns:
- The type solver with the requested configuration.
- Throws:
IllegalStateException
- if no build configuration is provided.
-