Class TypeSolverBuilder
- 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()
- Author:
- 4everTheOne
-
-
Constructor Summary
Constructors Constructor Description TypeSolverBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeSolver
build()
Convert the current build into a validTypeSolver
.TypeSolverBuilder
with(@NonNull TypeSolver typeSolver)
Append a costum type solver to the build.TypeSolverBuilder
withAAR(@NonNull File pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withAAR(@NonNull String pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withAAR(@NonNull Path pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withClassLoader(@NonNull ClassLoader classLoader)
Allow the type solver to resolve types using the providedClassLoader
.TypeSolverBuilder
withCurrentClassloader()
Allow the type solver to resolve types that are defined in the currentClassLoader
.TypeSolverBuilder
withCurrentJRE()
Allow the type solver to resolve types that are defined in the current Java Runtime Environment (JRE).TypeSolverBuilder
withJAR(@NonNull File pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withJAR(@NonNull String pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withJAR(@NonNull Path pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withSourceCode(@NonNull File pathToSourceCode)
Allow the type solver to resolve types using external source code.TypeSolverBuilder
withSourceCode(@NonNull String pathToSourceCode)
Allow the type solver to resolve types using external source code.TypeSolverBuilder
withSourceCode(@NonNull Path pathToSourceCode)
Allow the type solver to resolve types using external source code.
-
-
-
Method Detail
-
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:
ReflectionTypeSolver
-
withCurrentClassloader
public TypeSolverBuilder 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:
ReflectionTypeSolver
-
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:
JarTypeSolver
-
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:
JarTypeSolver
-
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:
JarTypeSolver
-
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:
AarTypeSolver
-
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:
AarTypeSolver
-
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:
AarTypeSolver
-
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:
JavaParserTypeSolver
-
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:
JavaParserTypeSolver
-
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:
JavaParserTypeSolver
-
withClassLoader
public TypeSolverBuilder withClassLoader(@NonNull ClassLoader classLoader)
Allow the type solver to resolve types using the providedClassLoader
.- Parameters:
classLoader
- The class loader to be registered.- Returns:
- the current builder.
- See Also:
ClassLoaderTypeSolver
-
build
public TypeSolver build()
Convert the current build into a validTypeSolver
.- Returns:
- The type solver with the requested configuration.
- Throws:
IllegalStateException
- if no build configuration is provided.
-
-