Skip to content

Commit df2912d

Browse files
committed
Improved name of empty handler
1 parent bdcb8f0 commit df2912d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/engineering/swat/watch/Watcher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class Watcher {
5454
private final Path path;
5555
private volatile Executor executor = CompletableFuture::runAsync;
5656

57-
private static final Consumer<WatchEvent> NULL_HANDLER = p -> {};
58-
private volatile Consumer<WatchEvent> eventHandler = NULL_HANDLER;
57+
private static final Consumer<WatchEvent> EMPTY_HANDLER = p -> {};
58+
private volatile Consumer<WatchEvent> eventHandler = EMPTY_HANDLER;
5959

6060

6161
private Watcher(WatchScope scope, Path path) {
@@ -100,7 +100,7 @@ public static Watcher watch(Path path, WatchScope scope) {
100100
* @return this for optional method chaining
101101
*/
102102
public Watcher on(Consumer<WatchEvent> eventHandler) {
103-
if (this.eventHandler != NULL_HANDLER) {
103+
if (this.eventHandler != EMPTY_HANDLER) {
104104
throw new IllegalArgumentException("on handler cannot be set more than once");
105105
}
106106
this.eventHandler = eventHandler;
@@ -111,7 +111,7 @@ public Watcher on(Consumer<WatchEvent> eventHandler) {
111111
* Convenience variant of {@link #on(Consumer)}, which allows you to only respond to certain events
112112
*/
113113
public Watcher on(WatchEventListener listener) {
114-
if (this.eventHandler != NULL_HANDLER) {
114+
if (this.eventHandler != EMPTY_HANDLER) {
115115
throw new IllegalArgumentException("on handler cannot be set more than once");
116116
}
117117
this.eventHandler = ev -> {
@@ -153,7 +153,7 @@ public Watcher withExecutor(Executor callbackHandler) {
153153
* @throws IllegalStateException the watchers is not configured correctly (for example, missing {@link #on(Consumer)}, or a watcher is started twice)
154154
*/
155155
public ActiveWatch start() throws IOException {
156-
if (this.eventHandler == NULL_HANDLER) {
156+
if (this.eventHandler == EMPTY_HANDLER) {
157157
throw new IllegalStateException("There is no onEvent handler defined");
158158
}
159159
switch (scope) {

0 commit comments

Comments
 (0)