Interface ClassLibraryBuilder

All Superinterfaces:
Serializable
All Known Implementing Classes:
OrderedClassLibraryBuilder, SortedClassLibraryBuilder

public interface ClassLibraryBuilder extends Serializable
This builder helps to construct a library. All kinds of sourcetypes are supported and it's up to the implementation how to bind these types. For instance: The SortedClassLibraryBuilder bundles all classloaders, all sourcefolders and all sources. The OrderedClassLibraryBuilder on the other hand keeps track of the order in which sourcetypes are added.
Since:
2.0
  • Method Details

    • appendClassLoader

      ClassLibraryBuilder appendClassLoader(ClassLoader classLoader)
      Append a classloader and return itself
      Parameters:
      classLoader - the classloader to add
      Returns:
      this ClassLibraryBuilder instance
    • appendDefaultClassLoaders

      ClassLibraryBuilder appendDefaultClassLoaders()
      Add the defaultClassLoaders and return itse
      Returns:
      this ClassLibraryBuilder instance
    • appendSourceFolder

      ClassLibraryBuilder appendSourceFolder(File sourceFolder)
      Parameters:
      sourceFolder - the source folder
      Returns:
      this ClassLibraryBuilder instance
    • appendSource

      ClassLibraryBuilder appendSource(InputStream stream) throws IOException
      Parameters:
      stream - the Java source as stream
      Returns:
      this ClassLibraryBuilder instance
      Throws:
      IOException - if an IOException is thrown, e.g. unsupported encoding
    • appendSource

      ClassLibraryBuilder appendSource(Reader reader)
      Parameters:
      reader - the Java source as reader
      Returns:
      this ClassLibraryBuilder instance
    • appendSource

      ClassLibraryBuilder appendSource(URL url) throws IOException
      Parameters:
      url - the Java source as URL
      Returns:
      this ClassLibraryBuilder instance
      Throws:
      IOException - if an IOException occurs
    • appendSource

      ClassLibraryBuilder appendSource(File file) throws IOException
      Parameters:
      file - the Java source as file
      Returns:
      this ClassLibraryBuilder instance
      Throws:
      IOException - if an IOException occurs
    • addSource

      JavaSource addSource(InputStream stream) throws IOException
      Parameters:
      stream - the Java source as stream
      Returns:
      the created JavaSource
      Throws:
      IOException - if an IOException is thrown, e.g. unsupported encoding
    • addSource

      JavaSource addSource(Reader reader)
      Add the source content of the reader to the ClassLibrary and return the generated JavaSource
      Parameters:
      reader - the Java source as reader
      Returns:
      the created JavaSource
    • addSource

      JavaSource addSource(URL url) throws IOException
      Parameters:
      url - the Java source as URL
      Returns:
      the created JavaSource
      Throws:
      IOException - if an IOException occurs
    • addSource

      JavaSource addSource(File file) throws IOException
      Parameters:
      file - the Java source as file
      Returns:
      the created JavaSource
      Throws:
      IOException - if an IOException occurs
    • setDebugLexer

      ClassLibraryBuilder setDebugLexer(boolean debugLexer)
      Set to true to enable debug logging for the lexer
      Parameters:
      debugLexer - the debug logging flag
      Returns:
      this ClassLibraryBuilder instance
    • setDebugParser

      ClassLibraryBuilder setDebugParser(boolean debugParser)
      Set to true to enable debug logging for the parser
      Parameters:
      debugParser - the debug logging flag
      Returns:
      this ClassLibraryBuilder instance
    • setEncoding

      ClassLibraryBuilder setEncoding(String encoding)
      Parameters:
      encoding - set the encoding
      Returns:
      this ClassLibraryBuilder instance
    • setModelBuilderFactory

      ClassLibraryBuilder setModelBuilderFactory(ModelBuilderFactory factory)
      Define the ModelBuilderFactory which the parsers should use to construct the JavaModel Objects
      Parameters:
      factory - the modelBuilderFactory
      Returns:
      this ClassLibraryBuilder instance
    • setModelWriterFactory

      ClassLibraryBuilder setModelWriterFactory(ModelWriterFactory factory)
      Define the ModelWriterFactory which is used by the classes when calling for the codeBlock.
      Parameters:
      factory - the modelWriterFactory
      Returns:
      this ClassLibraryBuilder instance
    • getClassLibrary

      ClassLibrary getClassLibrary()
      Get the library based on the strategy of the implementation
      Returns:
      the constructed ClassLibrary
    • setErrorHander

      ClassLibraryBuilder setErrorHander(ErrorHandler errorHandler)
      Can handle ParseExceptions instead of crashing. Has only effect on the appendSource() methods
      Parameters:
      errorHandler - the errorHandler
      Returns:
      this ClassLibraryBuilder instance
    • addSourceFolder

      JavaModule addSourceFolder(File sourceFolder)
      Parameters:
      sourceFolder - the sourcefolder
      Returns:
      the module info if the sourcefolder has a module-info.java, otherwise null
      Since:
      2.0