Class SourceStructure

java.lang.Object
io.spring.initializr.generator.language.SourceStructure

public class SourceStructure extends Object
Provide dedicated methods for a structure that holds sources.
Author:
Stephane Nicoll
  • Constructor Details

    • SourceStructure

      public SourceStructure(Path rootDirectory, Language language)
  • Method Details

    • getRootDirectory

      public Path getRootDirectory()
      Return the root directory of this structure. Can be used to access additional resources.
      Returns:
      the root directory
    • getSourcesDirectory

      public Path getSourcesDirectory()
      Return the sources directory of this structure.
      Returns:
      the sources directory
    • getResourcesDirectory

      public Path getResourcesDirectory()
      Return the resources directory of this structure.
      Returns:
      the resources directory
    • resolveSourceFile

      public Path resolveSourceFile(String packageName, String fileName)
      Resolve a source file.
      Parameters:
      packageName - the name of the package
      fileName - the name of the file (without its extension)
      Returns:
      the file to use to store a CompilationUnit with the specified package and name
      See Also:
    • createSourceFile

      public Path createSourceFile(String packageName, String fileName) throws IOException
      Create a source file, creating its package structure if necessary.
      Parameters:
      packageName - the name of the package
      fileName - the name of the file (without its extension)
      Returns:
      the file to use to store a CompilationUnit with the specified package and name
      Throws:
      IOException - if an error occurred while trying to create the directory structure or the file itself
      See Also:
    • resolveResourceFile

      public Path resolveResourceFile(String packageName, String file)
      Resolve a resource file defined in the specified package.
      Parameters:
      packageName - the name of the package
      file - the name of the file (including its extension)
      Returns:
      the file to use to store a resource with the specified package
      See Also:
    • createResourceFile

      public Path createResourceFile(String packageName, String file) throws IOException
      Create a resource file, creating its package structure if necessary.
      Parameters:
      packageName - the name of the package
      file - the name of the file (including its extension)
      Returns:
      the file to use to store a resource with the specified package
      Throws:
      IOException - if an error occurred while trying to create the directory structure or the file itself
      See Also: