Skip to content

Commit ace0c9b

Browse files
feffijknack
authored andcommitted
fixed minor code issues (jooby-project#1159)
1 parent 309140a commit ace0c9b

4 files changed

Lines changed: 6 additions & 12 deletions

File tree

‎modules/jooby-filewatcher/src/main/java/org/jooby/filewatcher/FileEventOptions.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@
207207

208208
import java.io.IOException;
209209
import java.nio.file.*;
210-
import java.nio.file.StandardWatchEventKinds;
211210
import java.nio.file.WatchEvent.Modifier;
212211
import java.util.ArrayList;
213212
import java.util.Arrays;
@@ -234,7 +233,7 @@
234233
*/
235234
public class FileEventOptions {
236235

237-
private List<WatchEvent.Kind<Path>> kinds = new ArrayList<>();
236+
private final List<WatchEvent.Kind<Path>> kinds = new ArrayList<>();
238237

239238
static final PathMatcher TRUE = new PathMatcher() {
240239

‎modules/jooby-filewatcher/src/main/java/org/jooby/filewatcher/FileMonitor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class FileMonitor implements Runnable {
249249

250250
@Inject
251251
public FileMonitor(final Injector injector, final Env env,
252-
final WatchService watcher, final Set<FileEventOptions> optionList) throws IOException {
252+
final WatchService watcher, final Set<FileEventOptions> optionList) {
253253
this.injector = injector;
254254
this.watcher = watcher;
255255
this.optionList = optionList;

‎modules/jooby-filewatcher/src/main/java/org/jooby/filewatcher/FileWatcher.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,7 @@ public void configure(final Env env, final Config conf, final Binder binder) thr
527527
this.watcher = FileSystems.getDefault().newWatchService();
528528
binder.bind(WatchService.class).toInstance(watcher);
529529
List<FileEventOptions> paths = new ArrayList<>();
530-
paths(env.getClass().getClassLoader(), conf, "filewatcher.register", options -> {
531-
paths.add(register(binder, options));
532-
});
530+
paths(env.getClass().getClassLoader(), conf, "filewatcher.register", options -> paths.add(register(binder, options)));
533531
for (Throwing.Function2<Config, Binder, FileEventOptions> binding : bindings) {
534532
paths.add(binding.apply(conf, binder));
535533
}
@@ -543,7 +541,7 @@ protected boolean empty() {
543541

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

560558
@SuppressWarnings("rawtypes")
561-
private void list(final Config conf, final String name, final Throwing.Consumer<Object> callback)
562-
throws Throwable {
559+
private void list(final Config conf, final String name, final Throwing.Consumer<Object> callback) {
563560
if (conf.hasPath(name)) {
564561
Object value = conf.getAnyRef(name);
565562
List values = value instanceof List ? (List) value : ImmutableList.of(value);

‎modules/jooby-filewatcher/src/main/java/org/jooby/filewatcher/FirstOfPathMatcher.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ class FirstOfPathMatcher implements PathMatcher {
218218
@Override
219219
public boolean matches(final Path path) {
220220
return matchers.stream()
221-
.filter(it -> it.matches(path))
222-
.findFirst()
223-
.isPresent();
221+
.anyMatch(it -> it.matches(path));
224222
}
225223

226224
@Override

0 commit comments

Comments
 (0)