From: Mateusz Warowny Date: Wed, 22 Feb 2023 13:28:59 +0000 (+0100) Subject: JAL-4130 Replace Collection#forEach call with for loop X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=08b2d95d2174021c3b201fc1afe7564bb354f503;p=jalview.git JAL-4130 Replace Collection#forEach call with for loop --- diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index 592a370..d6cf5b7 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -153,18 +153,21 @@ public class WebServicesMenuManager k -> new ArrayList<>()) .add(action); } - actionsByCategory.forEach((k, v) -> { + for (var entry : actionsByCategory.entrySet()) + { + var category = entry.getKey(); + var actions = entry.getValue(); // create submenu named {subcategory} with {service} or use root menu - var atMenu = k.isEmpty() ? menu : new JMenu(String.format("%s with %s", k, service.getName())); + var atMenu = category.isEmpty() ? menu : new JMenu(String.format("%s with %s", category, service.getName())); if (atMenu != menu) menu.add(atMenu); // add only if submenu // sort actions by name pulling nulls to the front - v.sort(Comparator.comparing( + actions.sort(Comparator.comparing( ActionI::getName, Comparator.nullsFirst(Comparator.naturalOrder()))); - for (int i = 0; i < v.size(); i++) { - addEntriesForAction(v.get(i), atMenu, atMenu == menu); + for (int i = 0; i < actions.size(); i++) { + addEntriesForAction(actions.get(i), atMenu, atMenu == menu); } - }); + } } }