You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/07/15 18:23:33 UTC
[commons-io] branch master updated: Use forEach()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 4e245350 Use forEach()
4e245350 is described below
commit 4e2453500299951e6a2ee3aa62266b35baac1786
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 15 14:23:27 2022 -0400
Use forEach()
---
.../commons/io/monitor/FileAlterationObserver.java | 23 +++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
index 3c87435d..2f3f8f96 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
@@ -230,9 +230,7 @@ public class FileAlterationObserver implements Serializable {
public void checkAndNotify() {
// fire onStart()
- for (final FileAlterationListener listener : listeners) {
- listener.onStart(this);
- }
+ listeners.forEach(listener -> listener.onStart(this));
// fire directory/file events
final File rootFile = rootEntry.getFile();
@@ -244,9 +242,7 @@ public class FileAlterationObserver implements Serializable {
// Else: Didn't exist and still doesn't
// fire onStop()
- for (final FileAlterationListener listener : listeners) {
- listener.onStop(this);
- }
+ listeners.forEach(listener -> listener.onStop(this));
}
/**
@@ -312,15 +308,14 @@ public class FileAlterationObserver implements Serializable {
* @param entry The file entry
*/
private void doCreate(final FileEntry entry) {
- for (final FileAlterationListener listener : listeners) {
+ listeners.forEach(listener -> {
if (entry.isDirectory()) {
listener.onDirectoryCreate(entry.getFile());
} else {
listener.onFileCreate(entry.getFile());
}
- }
- final FileEntry[] children = entry.getChildren();
- for (final FileEntry aChildren : children) {
+ });
+ for (final FileEntry aChildren : entry.getChildren()) {
doCreate(aChildren);
}
}
@@ -331,13 +326,13 @@ public class FileAlterationObserver implements Serializable {
* @param entry The file entry
*/
private void doDelete(final FileEntry entry) {
- for (final FileAlterationListener listener : listeners) {
+ listeners.forEach(listener -> {
if (entry.isDirectory()) {
listener.onDirectoryDelete(entry.getFile());
} else {
listener.onFileDelete(entry.getFile());
}
- }
+ });
}
/**
@@ -363,13 +358,13 @@ public class FileAlterationObserver implements Serializable {
*/
private void doMatch(final FileEntry entry, final File file) {
if (entry.refresh(file)) {
- for (final FileAlterationListener listener : listeners) {
+ listeners.forEach(listener -> {
if (entry.isDirectory()) {
listener.onDirectoryChange(file);
} else {
listener.onFileChange(file);
}
- }
+ });
}
}