Class LocalFileSystemAdapter

java.lang.Object
com.pragma.archetype.infrastructure.adapter.out.filesystem.LocalFileSystemAdapter
All Implemented Interfaces:
FileSystemPort

public class LocalFileSystemAdapter extends Object implements FileSystemPort
Adapter for local file system operations. Implements FileSystemPort using Java NIO.
  • Constructor Details

    • LocalFileSystemAdapter

      public LocalFileSystemAdapter()
  • Method Details

    • writeFile

      public void writeFile(GeneratedFile file)
      Description copied from interface: FileSystemPort
      Writes a file to the file system.
      Specified by:
      writeFile in interface FileSystemPort
      Parameters:
      file - the file to write
    • writeFiles

      public void writeFiles(List<GeneratedFile> files)
      Description copied from interface: FileSystemPort
      Writes multiple files to the file system.
      Specified by:
      writeFiles in interface FileSystemPort
      Parameters:
      files - the files to write
    • createDirectory

      public void createDirectory(Path path)
      Description copied from interface: FileSystemPort
      Creates a directory.
      Specified by:
      createDirectory in interface FileSystemPort
      Parameters:
      path - the directory path
    • exists

      public boolean exists(Path path)
      Description copied from interface: FileSystemPort
      Checks if a path exists.
      Specified by:
      exists in interface FileSystemPort
      Parameters:
      path - the path to check
      Returns:
      true if exists, false otherwise
    • directoryExists

      public boolean directoryExists(Path path)
      Description copied from interface: FileSystemPort
      Checks if a directory exists.
      Specified by:
      directoryExists in interface FileSystemPort
      Parameters:
      path - the directory path
      Returns:
      true if exists and is a directory, false otherwise
    • isProjectEmpty

      public boolean isProjectEmpty(Path path)
      Description copied from interface: FileSystemPort
      Checks if a directory is empty (only contains Gradle files).
      Specified by:
      isProjectEmpty in interface FileSystemPort
      Parameters:
      path - the directory path
      Returns:
      true if empty or only contains allowed files, false otherwise
    • listFiles

      public List<Path> listFiles(Path path)
      Description copied from interface: FileSystemPort
      Lists files in a directory.
      Specified by:
      listFiles in interface FileSystemPort
      Parameters:
      path - the directory path
      Returns:
      list of file paths
    • readFile

      public String readFile(Path path)
      Description copied from interface: FileSystemPort
      Reads the content of a file.
      Specified by:
      readFile in interface FileSystemPort
      Parameters:
      path - the file path
      Returns:
      the file content as string
    • appendToFile

      public void appendToFile(Path path, String content)
      Description copied from interface: FileSystemPort
      Appends content to an existing file.
      Specified by:
      appendToFile in interface FileSystemPort
      Parameters:
      path - the file path
      content - the content to append