Class FileTraverserImpl

java.lang.Object
org.pwss.io_file.FileTraverserImpl
All Implemented Interfaces:
FileTraverser

public final class FileTraverserImpl extends Object implements FileTraverser
The FileTraverseImpl class provides an implementation of the FileTraverser interface. Uses File as traversing strategy
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new instance of the FileTraverserImpl class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Shuts down thread pools and closes resources used by this file traverser instance.
    final Future<List<File>>
    traverse(File folder)
    Asynchronously traverses the given folder, returning a list of files within the folder as a Future.
    final Future<List<File>>
    Asynchronously traverses the directory represented by the given string path, returning a list of files within the directory as a Future.
    final Future<List<File>>
    traverse(Path path)
    Asynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FileTraverserImpl

      public FileTraverserImpl()
      Constructs a new instance of the FileTraverserImpl class. Initializes an executor service with a fixed thread pool size and sets up a logger for this implementation.
  • Method Details

    • traverse

      public final Future<List<File>> traverse(Path path)
      Description copied from interface: FileTraverser
      Asynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.
      Specified by:
      traverse in interface FileTraverser
      Parameters:
      path - The directory path to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the directory
    • traverse

      public final Future<List<File>> traverse(String path)
      Description copied from interface: FileTraverser
      Asynchronously traverses the directory represented by the given string path, returning a list of files within the directory as a Future.
      Specified by:
      traverse in interface FileTraverser
      Parameters:
      path - The directory path (as a String) to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the directory
    • shutdownThreadPool

      public final void shutdownThreadPool()
      Description copied from interface: FileTraverser
      Shuts down thread pools and closes resources used by this file traverser instance. This method should be called when the traverser is no longer needed to ensure that all threads are properly shut down and resources are released.
      Specified by:
      shutdownThreadPool in interface FileTraverser
    • traverse

      public final Future<List<File>> traverse(File folder)
      Description copied from interface: FileTraverser
      Asynchronously traverses the given folder, returning a list of files within the folder as a Future. This is the core method where the traversing logic happens. The other two overloaded variants transform their respective input parameters into a File object and then invoke this method.
      Specified by:
      traverse in interface FileTraverser
      Parameters:
      folder - The folder to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the folder