From a547ca4fcced07c36e60735a79fb657fc32e6ac2 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 22 Feb 2023 14:27:43 +0100 Subject: [PATCH] JAL-4130 Avoid using thenComparing of the Comparator interface --- src/jalview/ws2/gui/WebServicesMenuManager.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index c9b53a9..592a370 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -120,9 +120,13 @@ public class WebServicesMenuManager private void addOneshotEntries(List> services, JMenu menu) { - services.sort(Comparator - ., String> comparing(s -> s.getUrl().toString()) - .thenComparing(WebService::getName)); + // Workaround. Comparator methods not working in j2s + services.sort((ws1, ws2) -> { + var res = ws1.getUrl().toString().compareTo(ws2.getUrl().toString()); + if (res == 0) + res = ws1.getName().compareTo(ws2.getName()); + return res; + }); URL lastHost = null; for (WebService service : services) { @@ -291,9 +295,12 @@ public class WebServicesMenuManager private void buildAlternativesMenu(List> services) { var menu = alternativesMenu; - services.sort(Comparator - ., String> comparing(s -> s.getUrl().toString()) - .thenComparing(s -> s.getName())); + services.sort((ws1, ws2) -> { + var res = ws1.getUrl().toString().compareTo(ws2.getUrl().toString()); + if (res == 0) + res = ws1.getName().compareTo(ws2.getName()); + return res; + }); URL lastHost = null; for (var service : services) { -- 1.7.10.2