public class DirectoryWatcher
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DirectoryWatcher.Builder
A builder for a
DirectoryWatcher. |
| Constructor and Description |
|---|
DirectoryWatcher(java.util.List<java.nio.file.Path> paths,
DirectoryChangeListener listener,
java.nio.file.WatchService watchService,
FileHasher fileHasher,
FileTreeVisitor fileTreeVisitor,
org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
static DirectoryWatcher.Builder |
builder()
Get a new builder for a
DirectoryWatcher. |
void |
close() |
DirectoryChangeListener |
getListener() |
boolean |
isClosed() |
java.util.Map<java.nio.file.Path,FileHash> |
pathHashes() |
void |
watch()
Watch for changes; block until the listener stops listening or the watcher is closed.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
watchAsync()
Asynchronously watch the directories using
ForkJoinPool.commonPool() as the executor |
java.util.concurrent.CompletableFuture<java.lang.Void> |
watchAsync(java.util.concurrent.Executor executor)
Start watching for changes asynchronously.
|
public DirectoryWatcher(java.util.List<java.nio.file.Path> paths,
DirectoryChangeListener listener,
java.nio.file.WatchService watchService,
FileHasher fileHasher,
FileTreeVisitor fileTreeVisitor,
org.slf4j.Logger logger)
public static DirectoryWatcher.Builder builder()
DirectoryWatcher.public java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync()
ForkJoinPool.commonPool() as the executorpublic java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync(java.util.concurrent.Executor executor)
The future completes when the listener stops listening or the watcher is closed.
This method will block until the watcher is initialized and successfully watching.
executor - the executor to use to watch asynchronouslypublic void watch()
java.lang.IllegalStateException - if the directory watcher is closed when watch() is called.public java.util.Map<java.nio.file.Path,FileHash> pathHashes()
public DirectoryChangeListener getListener()
public void close()
throws java.io.IOException
java.io.IOExceptionpublic boolean isClosed()