From 08b2d95d2174021c3b201fc1afe7564bb354f503 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 22 Feb 2023 14:28:59 +0100 Subject: [PATCH] JAL-4130 Replace Collection#forEach call with for loop --- src/jalview/ws2/gui/WebServicesMenuManager.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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); } - }); + } } } -- 1.7.10.2