Package org.forgerock.util
Class DirectoryWatcher.ChangeListener
- java.lang.Object
-
- org.forgerock.util.DirectoryWatcher.ChangeListener
-
- Enclosing class:
- DirectoryWatcher
public class DirectoryWatcher.ChangeListener extends Object
A change listener for a single directory that can be used to register notification callbacks and to cancel observing this directory.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels this change listener.DirectoryWatcher.ChangeListener
onChange(BiConsumer<Path,WatchEvent.Kind<Path>> consumer)
Registers a listener to be notified of change events for this directory.DirectoryWatcher.ChangeListener
onOverflow(Runnable action)
Registers a callback to be notified when the underlying watch service lost some change events due to overflow.String
toString()
-
-
-
Method Detail
-
cancel
public void cancel()
Cancels this change listener.
-
onChange
public DirectoryWatcher.ChangeListener onChange(BiConsumer<Path,WatchEvent.Kind<Path>> consumer)
Registers a listener to be notified of change events for this directory.- Parameters:
consumer
- the callback that will be given the normalized absolute path of the file that changed and the kind of change event.- Returns:
- this change listener.
-
onOverflow
public DirectoryWatcher.ChangeListener onOverflow(Runnable action)
Registers a callback to be notified when the underlying watch service lost some change events due to overflow.- Parameters:
action
- the action to perform when the watch service loses events due to overflow.- Returns:
- this change listener.
-
-