Package io.methvin.watcher
Class DirectoryWatcher
java.lang.Object
io.methvin.watcher.DirectoryWatcher
public class DirectoryWatcher
extends java.lang.Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DirectoryWatcher.Builder
A builder for aDirectoryWatcher
. -
Constructor Summary
Constructors Constructor Description DirectoryWatcher(java.util.List<java.nio.file.Path> paths, DirectoryChangeListener listener, java.nio.file.WatchService watchService, FileHasher fileHasher, org.slf4j.Logger logger)
-
Method Summary
Modifier and Type Method Description static DirectoryWatcher.Builder
builder()
Get a new builder for aDirectoryWatcher
.void
close()
DirectoryChangeListener
getListener()
boolean
isClosed()
java.util.Map<java.nio.file.Path,FileHash>
pathHashes()
void
watch()
Watch the directories.java.util.concurrent.CompletableFuture<java.lang.Void>
watchAsync()
Asynchronously watch the directories usingForkJoinPool.commonPool()
as the executorjava.util.concurrent.CompletableFuture<java.lang.Void>
watchAsync(java.util.concurrent.Executor executor)
Asynchronously watch the directories.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
DirectoryWatcher
public DirectoryWatcher(java.util.List<java.nio.file.Path> paths, DirectoryChangeListener listener, java.nio.file.WatchService watchService, FileHasher fileHasher, org.slf4j.Logger logger) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
builder
Get a new builder for aDirectoryWatcher
. -
watchAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync()Asynchronously watch the directories usingForkJoinPool.commonPool()
as the executor -
watchAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync(java.util.concurrent.Executor executor)Asynchronously watch the directories.- Parameters:
executor
- the executor to use to watch asynchronously
-
pathHashes
-
watch
public void watch()Watch the directories. Block until either the listener stops watching or the DirectoryWatcher is closed. -
getListener
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
-