Class 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 Detail

      • TypeSolverBuilder

        public TypeSolverBuilder()
    • 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 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:
        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
      • 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.