Package io.methvin.watcher
Class DirectoryWatcher.Builder
- java.lang.Object
-
- io.methvin.watcher.DirectoryWatcher.Builder
-
- Enclosing class:
- DirectoryWatcher
public static final class DirectoryWatcher.Builder extends java.lang.Object
A builder for aDirectoryWatcher
. UseDirectoryWatcher.builder()
to get a new instance.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectoryWatcher
build()
DirectoryWatcher.Builder
fileHasher(FileHasher fileHasher)
Defines the file hasher to be used by the watcher.DirectoryWatcher.Builder
fileHashing(boolean enabled)
Defines whether file hashing should be used to catch duplicate events.DirectoryWatcher.Builder
fileTreeVisitor(FileTreeVisitor fileTreeVisitor)
Defines the file tree visitor to be used by the watcher.DirectoryWatcher.Builder
listener(DirectoryChangeListener listener)
Set a listener that will be called when a directory change event occurs.DirectoryWatcher.Builder
logger(org.slf4j.Logger logger)
Set a logger to be used by the watcher.DirectoryWatcher.Builder
path(java.nio.file.Path path)
Set a single path to watch.DirectoryWatcher.Builder
paths(java.util.List<java.nio.file.Path> paths)
Set multiple paths to watch.DirectoryWatcher.Builder
watchService(java.nio.file.WatchService watchService)
Set aWatchService
implementation that will be used by the watcher.
-
-
-
Method Detail
-
paths
public DirectoryWatcher.Builder paths(java.util.List<java.nio.file.Path> paths)
Set multiple paths to watch.
-
path
public DirectoryWatcher.Builder path(java.nio.file.Path path)
Set a single path to watch.
-
listener
public DirectoryWatcher.Builder listener(DirectoryChangeListener listener)
Set a listener that will be called when a directory change event occurs.
-
watchService
public DirectoryWatcher.Builder watchService(java.nio.file.WatchService watchService)
Set aWatchService
implementation that will be used by the watcher.By default, this detects your OS and either uses the native JVM watcher or the macOS watcher.
-
logger
public DirectoryWatcher.Builder logger(org.slf4j.Logger logger)
Set a logger to be used by the watcher. This defaults toLoggerFactory.getLogger(DirectoryWatcher.class)
-
fileHashing
public DirectoryWatcher.Builder fileHashing(boolean enabled)
Defines whether file hashing should be used to catch duplicate events. Defaults totrue
.
-
fileHasher
public DirectoryWatcher.Builder fileHasher(FileHasher fileHasher)
Defines the file hasher to be used by the watcher.Note: will implicitly enable file hashing. Setting to null is equivalent to
fileHashing(false)
-
fileTreeVisitor
public DirectoryWatcher.Builder fileTreeVisitor(FileTreeVisitor fileTreeVisitor)
Defines the file tree visitor to be used by the watcher.
-
build
public DirectoryWatcher build() throws java.io.IOException
- Throws:
java.io.IOException
-
-