From e26c2ff31ce6aee70d4459adf234f1fac521c311 Mon Sep 17 00:00:00 2001 From: dev-mlb <19797865+dev-mlb@users.noreply.github.com> Date: Wed, 29 May 2024 18:23:21 -0400 Subject: [PATCH] errorprone :: ForEachIterable (#807) --- src/main/java/emissary/directory/DirectoryEntryList.java | 4 +--- src/main/java/emissary/directory/DirectoryEntryMap.java | 4 +--- src/main/java/emissary/pool/MoveSpool.java | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/emissary/directory/DirectoryEntryList.java b/src/main/java/emissary/directory/DirectoryEntryList.java index 2b0c646c8c..cd31b5983f 100755 --- a/src/main/java/emissary/directory/DirectoryEntryList.java +++ b/src/main/java/emissary/directory/DirectoryEntryList.java @@ -9,7 +9,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.annotation.Nullable; @@ -248,8 +247,7 @@ public DirectoryEntry pickOneOf(final int desiredExpense) { public static DirectoryEntryList fromXML(final Element e) { final DirectoryEntryList d = new DirectoryEntryList(); final List entryElements = e.getChildren(DirectoryEntry.ENTRY); - for (Iterator i = entryElements.iterator(); i.hasNext();) { - final Element entryElement = i.next(); + for (Element entryElement : entryElements) { d.add(DirectoryEntry.fromXml(entryElement)); } return d; diff --git a/src/main/java/emissary/directory/DirectoryEntryMap.java b/src/main/java/emissary/directory/DirectoryEntryMap.java index 7ab3466b93..3f3dcf35a4 100644 --- a/src/main/java/emissary/directory/DirectoryEntryMap.java +++ b/src/main/java/emissary/directory/DirectoryEntryMap.java @@ -4,7 +4,6 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -323,8 +322,7 @@ public int countAllMatching(final String key) { int count = 0; for (final DirectoryEntryList list : values()) { - for (final Iterator i = list.iterator(); i.hasNext();) { - final DirectoryEntry entry = i.next(); + for (DirectoryEntry entry : list) { if (KeyManipulator.gmatch(entry.getKey(), key)) { count++; } diff --git a/src/main/java/emissary/pool/MoveSpool.java b/src/main/java/emissary/pool/MoveSpool.java index bbc3d1da1f..0f8a686885 100755 --- a/src/main/java/emissary/pool/MoveSpool.java +++ b/src/main/java/emissary/pool/MoveSpool.java @@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -120,8 +119,7 @@ public void quit() { */ private IDirectoryPlace getLocalDirectory() { if (localDirectory == null) { - for (Iterator i = Namespace.keySet().iterator(); i.hasNext();) { - String key = i.next(); + for (String key : Namespace.keySet()) { try { Object value = Namespace.lookup(key); if (value instanceof IDirectoryPlace) {