Class AutoUpdatingDirectory<T extends WatchedFileListener>

java.lang.Object
ca.on.oicr.gsi.shesmu.plugin.files.AutoUpdatingDirectory<T>
Type Parameters:
T - the wrapper class for updating each file

public final class AutoUpdatingDirectory<T extends WatchedFileListener> extends Object
Creates a repository of updating files stored in a directory
  • Constructor Details

    • AutoUpdatingDirectory

      public AutoUpdatingDirectory(FileWatcher watcher, String extension, Function<Path,T> ctor)
      Creates a new automatically updating directory
      Parameters:
      watcher - the file watcher to use
      extension - the file extension for the files that should be loaded
      ctor - a constructor to create a new self-updating file for a path
    • AutoUpdatingDirectory

      public AutoUpdatingDirectory(String extension, Function<Path,T> ctor)
      Creates a new automatically updating directory
      Parameters:
      extension - the file extension for the files that should be loaded
      ctor - a constructor to create a new self-updating file for a path
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Check if there are no files currently detected
      Returns:
      true if there are no files currently detected; false otherwise
    • stream

      public Stream<T> stream()
      Access all entries detected for each file
      Returns:
      a stream of all values
    • subscribe

      public Runnable subscribe(Runnable callback)
      Register a callback to invoke whenever a new file is detected.
      Parameters:
      callback - the callback to invoke
      Returns:
      a mechanism to unsubscribe this callback