5353 * <p>It will avoid common errors using the raw apis, and will try to use the most native api where possible.</p>
5454 * Note, there are differences per platform that cannot be avoided, please review the readme of the library.
5555 */
56- public class Watcher {
56+ public class Watch {
5757 private final Logger logger = LogManager .getLogger ();
5858 private final Path path ;
5959 private final WatchScope scope ;
@@ -65,7 +65,7 @@ public class Watcher {
6565 private static final Predicate <WatchEvent > TRUE_FILTER = e -> true ;
6666 private volatile Predicate <WatchEvent > eventFilter = TRUE_FILTER ;
6767
68- private Watcher (Path path , WatchScope scope ) {
68+ private Watch (Path path , WatchScope scope ) {
6969 this .path = path ;
7070 this .scope = scope ;
7171 }
@@ -76,7 +76,7 @@ private Watcher(Path path, WatchScope scope) {
7676 * @param scope for directories you can also choose to monitor it's direct children or all it's descendants
7777 * @throws IllegalArgumentException in case a path is not supported (in relation to the scope)
7878 */
79- public static Watcher watch (Path path , WatchScope scope ) {
79+ public static Watch build (Path path , WatchScope scope ) {
8080 if (!path .isAbsolute ()) {
8181 throw new IllegalArgumentException ("We can only watch absolute paths" );
8282 }
@@ -95,7 +95,7 @@ public static Watcher watch(Path path, WatchScope scope) {
9595 default :
9696 throw new IllegalArgumentException ("Unsupported scope: " + scope );
9797 }
98- return new Watcher (path , scope );
98+ return new Watch (path , scope );
9999 }
100100
101101 /**
@@ -105,7 +105,7 @@ public static Watcher watch(Path path, WatchScope scope) {
105105 * @param eventHandler a callback that handles the watch event, will be called once per event.
106106 * @return this for optional method chaining
107107 */
108- public Watcher on (Consumer <WatchEvent > eventHandler ) {
108+ public Watch on (Consumer <WatchEvent > eventHandler ) {
109109 if (this .eventHandler != EMPTY_HANDLER ) {
110110 throw new IllegalArgumentException ("on handler cannot be set more than once" );
111111 }
@@ -116,7 +116,7 @@ public Watcher on(Consumer<WatchEvent> eventHandler) {
116116 /**
117117 * Convenience variant of {@link #on(Consumer)}, which allows you to only respond to certain events
118118 */
119- public Watcher on (WatchEventListener listener ) {
119+ public Watch on (WatchEventListener listener ) {
120120 if (this .eventHandler != EMPTY_HANDLER ) {
121121 throw new IllegalArgumentException ("on handler cannot be set more than once" );
122122 }
@@ -149,7 +149,7 @@ public Watcher on(WatchEventListener listener) {
149149 * ({@code true}) or dropped ({@code false})
150150 * @return {@code this} (to support method chaining)
151151 */
152- Watcher filter (Predicate <WatchEvent > predicate ) {
152+ Watch filter (Predicate <WatchEvent > predicate ) {
153153 if (this .eventFilter != TRUE_FILTER ) {
154154 throw new IllegalArgumentException ("filter cannot be set more than once" );
155155 }
@@ -163,7 +163,7 @@ Watcher filter(Predicate<WatchEvent> predicate) {
163163 * @param callbackHandler worker pool to use
164164 * @return this for optional method chaining
165165 */
166- public Watcher withExecutor (Executor callbackHandler ) {
166+ public Watch withExecutor (Executor callbackHandler ) {
167167 this .executor = callbackHandler ;
168168 return this ;
169169 }
@@ -179,7 +179,7 @@ public Watcher withExecutor(Executor callbackHandler) {
179179 * files/directories to approximate
180180 * @return This watcher for optional method chaining
181181 */
182- public Watcher onOverflow (Approximation whichFiles ) {
182+ public Watch onOverflow (Approximation whichFiles ) {
183183 this .approximateOnOverflow = whichFiles ;
184184 return this ;
185185 }
0 commit comments