Class TypeSolverBuilder
- java.lang.Object
-
- com.github.javaparser.symbolsolver.resolution.typesolvers.TypeSolverBuilder
-
public class TypeSolverBuilder extends java.lang.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 Summary
Fields Modifier and Type Field Description private java.util.List<TypeSolver>
typeSolvers
-
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 java.io.File pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withAAR(@NonNull java.lang.String pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withAAR(@NonNull java.nio.file.Path pathToAar)
Allow the type solver to resolve types that are defined in a AAR file.TypeSolverBuilder
withClassLoader(@NonNull java.lang.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 java.io.File pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withJAR(@NonNull java.lang.String pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withJAR(@NonNull java.nio.file.Path pathToJar)
Allow the type solver to resolve types that are defined in a JAR file.TypeSolverBuilder
withSourceCode(@NonNull java.io.File pathToSourceCode)
Allow the type solver to resolve types using external source code.TypeSolverBuilder
withSourceCode(@NonNull java.lang.String pathToSourceCode)
Allow the type solver to resolve types using external source code.TypeSolverBuilder
withSourceCode(@NonNull java.nio.file.Path pathToSourceCode)
Allow the type solver to resolve types using external source code.
-
-
-
Field Detail
-
typeSolvers
private final java.util.List<TypeSolver> typeSolvers
-
-
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 java.nio.file.Path pathToJar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the Jar.- See Also:
JarTypeSolver
-
withJAR
public TypeSolverBuilder withJAR(@NonNull java.io.File pathToJar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the Jar.- See Also:
JarTypeSolver
-
withJAR
public TypeSolverBuilder withJAR(@NonNull java.lang.String pathToJar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the Jar.- See Also:
JarTypeSolver
-
withAAR
public TypeSolverBuilder withAAR(@NonNull java.nio.file.Path pathToAar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the AAR.- See Also:
AarTypeSolver
-
withAAR
public TypeSolverBuilder withAAR(@NonNull java.io.File pathToAar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the AAR.- See Also:
AarTypeSolver
-
withAAR
public TypeSolverBuilder withAAR(@NonNull java.lang.String pathToAar) throws java.io.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:
java.io.IOException
- If an I/O exception occurs while reading the AAR.- See Also:
AarTypeSolver
-
withSourceCode
public TypeSolverBuilder withSourceCode(@NonNull java.nio.file.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 java.io.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 java.lang.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 java.lang.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:
java.lang.IllegalStateException
- if no build configuration is provided.
-
-