Package org.miaixz.bus.core.io.watch
Class WatcherChain
java.lang.Object
org.miaixz.bus.core.io.watch.WatcherChain
观察者链
用于加入多个观察者
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription加入责任链iterator()static WatcherChain创建观察者链WatcherChainvoidonCreate(WatchEvent<?> event, WatchKey key) 文件创建时执行的方法voidonDelete(WatchEvent<?> event, WatchKey key) 文件删除时执行的方法voidonModify(WatchEvent<?> event, WatchKey key) 文件修改时执行的方法 文件修改可能触发多次voidonOverflow(WatchEvent<?> event, WatchKey key) 事件丢失或出错时执行的方法Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
WatcherChain
构造- Parameters:
watchers- 观察者列表
-
-
Method Details
-
of
创建观察者链WatcherChain- Parameters:
watchers- 观察者列表- Returns:
WatcherChain
-
onCreate
Description copied from interface:Watcher文件创建时执行的方法- Specified by:
onCreatein interfaceWatcher- Parameters:
event- 事件,可通过WatchEvent.context()获取创建的文件或目录名称key- 事件发生的WatchKey,可以通过WatchKey.watchable()获取监听的Path路径
-
onModify
Description copied from interface:Watcher文件修改时执行的方法 文件修改可能触发多次- Specified by:
onModifyin interfaceWatcher- Parameters:
event- 事件,可通过WatchEvent.context()获取创建的文件或目录名称key- 事件发生的WatchKey,可以通过WatchKey.watchable()获取监听的Path路径
-
onDelete
Description copied from interface:Watcher文件删除时执行的方法- Specified by:
onDeletein interfaceWatcher- Parameters:
event- 事件,可通过WatchEvent.context()获取创建的文件或目录名称key- 事件发生的WatchKey,可以通过WatchKey.watchable()获取监听的Path路径
-
onOverflow
Description copied from interface:Watcher事件丢失或出错时执行的方法- Specified by:
onOverflowin interfaceWatcher- Parameters:
event- 事件,可通过WatchEvent.context()获取创建的文件或目录名称key- 事件发生的WatchKey,可以通过WatchKey.watchable()获取监听的Path路径
-
iterator
-
addChain
Description copied from interface:Chain加入责任链- Specified by:
addChainin interfaceChain<Watcher,WatcherChain> - Parameters:
element- 责任链新的环节元素- Returns:
- this
-