Class WatcherChain

java.lang.Object
org.aoju.bus.core.io.watcher.WatcherChain
All Implemented Interfaces:
Iterable<Watcher>, Watcher, Chain<Watcher,WatcherChain>

public class WatcherChain extends Object implements Watcher, Chain<Watcher,WatcherChain>
观察者链 用于加入多个观察者
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • WatcherChain

      public WatcherChain(Watcher... watchers)
      构造
      Parameters:
      watchers - 观察者列表
  • Method Details

    • create

      public static WatcherChain create(Watcher... watchers)
      创建观察者链WatcherChain
      Parameters:
      watchers - 观察者列表
      Returns:
      WatcherChain
    • onCreate

      public void onCreate(WatchEvent<?> event, Path currentPath)
      Description copied from interface: Watcher
      文件创建时执行的方法
      Specified by:
      onCreate in interface Watcher
      Parameters:
      event - 事件
      currentPath - 事件发生的当前Path路径
    • onModify

      public void onModify(WatchEvent<?> event, Path currentPath)
      Description copied from interface: Watcher
      文件修改时执行的方法 文件修改可能触发多次
      Specified by:
      onModify in interface Watcher
      Parameters:
      event - 事件
      currentPath - 事件发生的当前Path路径
    • onDelete

      public void onDelete(WatchEvent<?> event, Path currentPath)
      Description copied from interface: Watcher
      文件删除时执行的方法
      Specified by:
      onDelete in interface Watcher
      Parameters:
      event - 事件
      currentPath - 事件发生的当前Path路径
    • onOverflow

      public void onOverflow(WatchEvent<?> event, Path currentPath)
      Description copied from interface: Watcher
      事件丢失或出错时执行的方法
      Specified by:
      onOverflow in interface Watcher
      Parameters:
      event - 事件
      currentPath - 事件发生的当前Path路径
    • iterator

      public Iterator<Watcher> iterator()
      Specified by:
      iterator in interface Iterable<Watcher>
    • addChain

      public WatcherChain addChain(Watcher element)
      Description copied from interface: Chain
      加入责任链
      Specified by:
      addChain in interface Chain<Watcher,WatcherChain>
      Parameters:
      element - 责任链新的环节元素
      Returns:
      this