Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -234,7 +233,7 @@
*/
public class FileEventOptions {

private List<WatchEvent.Kind<Path>> kinds = new ArrayList<>();
private final List<WatchEvent.Kind<Path>> kinds = new ArrayList<>();

static final PathMatcher TRUE = new PathMatcher() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class FileMonitor implements Runnable {

@Inject
public FileMonitor(final Injector injector, final Env env,
final WatchService watcher, final Set<FileEventOptions> optionList) throws IOException {
final WatchService watcher, final Set<FileEventOptions> optionList) {
this.injector = injector;
this.watcher = watcher;
this.optionList = optionList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ public void configure(final Env env, final Config conf, final Binder binder) thr
this.watcher = FileSystems.getDefault().newWatchService();
binder.bind(WatchService.class).toInstance(watcher);
List<FileEventOptions> paths = new ArrayList<>();
paths(env.getClass().getClassLoader(), conf, "filewatcher.register", options -> {
paths.add(register(binder, options));
});
paths(env.getClass().getClassLoader(), conf, "filewatcher.register", options -> paths.add(register(binder, options)));
for (Throwing.Function2<Config, Binder, FileEventOptions> binding : bindings) {
paths.add(binding.apply(conf, binder));
}
Expand All @@ -543,7 +541,7 @@ protected boolean empty() {

@SuppressWarnings({"unchecked", "rawtypes"})
private void paths(final ClassLoader loader, final Config conf, final String name,
final Consumer<FileEventOptions> callback) throws Throwable {
final Consumer<FileEventOptions> callback) {
list(conf, name, value -> {
Config coptions = ConfigFactory.parseMap((Map) value);
Class handler = loader.loadClass(coptions.getString("handler"));
Expand All @@ -558,8 +556,7 @@ private void paths(final ClassLoader loader, final Config conf, final String nam
}

@SuppressWarnings("rawtypes")
private void list(final Config conf, final String name, final Throwing.Consumer<Object> callback)
throws Throwable {
private void list(final Config conf, final String name, final Throwing.Consumer<Object> callback) {
if (conf.hasPath(name)) {
Object value = conf.getAnyRef(name);
List values = value instanceof List ? (List) value : ImmutableList.of(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ class FirstOfPathMatcher implements PathMatcher {
@Override
public boolean matches(final Path path) {
return matchers.stream()
.filter(it -> it.matches(path))
.findFirst()
.isPresent();
.anyMatch(it -> it.matches(path));
}

@Override
Expand Down