Interface WorkingDirectoryDestroyer

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface WorkingDirectoryDestroyer
    A strategy interface to destroy the working directory.

    This interface allows implementing different strategies for cleaning up the working directory, such as deleting all files, specific files, or doing nothing.

    Since:
    4.0.0
    Author:
    Dmytro Nosan
    See Also:
    deleteAll(), deleteOnly(String...), doNothing()
    • Method Detail

      • deleteAll

        static WorkingDirectoryDestroyer deleteAll()
        Completely deletes the working directory.
        Returns:
        A new working directory destroyer
      • deleteOnly

        static WorkingDirectoryDestroyer deleteOnly​(String... paths)
        Deletes the specified paths in the working directory.
        Parameters:
        paths - Paths within the working directory to delete (e.g., lib, bin, tools, conf/cassandra.yaml)
        Returns:
        A new working directory destroyer
        Throws:
        NullPointerException - If the paths or any of their elements are null
        IllegalArgumentException - If any path points outside the working directory
      • doNothing

        static WorkingDirectoryDestroyer doNothing()
        Does nothing to the working directory. In other words, leaves it as it is.
        Returns:
        A new working directory destroyer
      • destroy

        void destroy​(Path workingDirectory,
                     Version version)
              throws IOException
        Destroys the working directory based on the implemented strategy.
        Parameters:
        workingDirectory - The working directory
        version - The Cassandra version
        Throws:
        IOException - If an I/O error occurs