File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed
src/main/java/engineering/swat/watch/impl/mac Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -59,20 +59,28 @@ interface NativeEventHandler {
5959 <T > void handle (java .nio .file .WatchEvent .Kind <T > kind , @ Nullable T context );
6060
6161 default void handle (int kindOrdinal , String rootPath , String relativePath ) {
62- if (kindOrdinal == Kind .OVERFLOW .ordinal ()) {
63- handle (OVERFLOW , null );
64- } else {
65- var context = Path .of (rootPath ).relativize (Path .of (relativePath ));
66- var kind =
67- kindOrdinal == Kind .CREATE .ordinal () ? ENTRY_CREATE :
68- kindOrdinal == Kind .MODIFY .ordinal () ? ENTRY_MODIFY :
69- kindOrdinal == Kind .DELETE .ordinal () ? ENTRY_DELETE : null ;
70-
71- if (kind != null ) {
72- handle (kind , context );
62+ if (kindOrdinal < Kind .values ().length ) {
63+ var kind = Kind .values ()[kindOrdinal ];
64+ switch (kind ) {
65+ case CREATE :
66+ handle (ENTRY_CREATE , toContext (rootPath , relativePath ));
67+ break ;
68+ case MODIFY :
69+ handle (ENTRY_MODIFY , toContext (rootPath , relativePath ));
70+ break ;
71+ case DELETE :
72+ handle (ENTRY_DELETE , toContext (rootPath , relativePath ));
73+ break ;
74+ case OVERFLOW :
75+ handle (OVERFLOW , null );
76+ break ;
7377 }
7478 }
7579 }
80+
81+ static Path toContext (String rootPath , String relativePath ) {
82+ return Path .of (rootPath ).relativize (Path .of (relativePath ));
83+ }
7684}
7785
7886enum Kind {
You can’t perform that action at this time.
0 commit comments