From f7c23deb8fed6948bd9be152969ad352fa96279c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 19 Jul 2023 21:43:53 +0300 Subject: [PATCH] Use Stream.toList instead of Collectors --- .../docker/core/AbstractRegistry.java | 8 +++--- .../docker/core/DockerConnectionManager.java | 27 +++++++++---------- .../internal/docker/core/RepositoryTagV2.java | 4 +-- .../CleanDockerExplorerRequirement.java | 5 ++-- .../docker/core/CopyFromDockerJobTest.java | 13 +++++---- .../internal/docker/core/DockerImageTest.java | 3 +-- ...DockerConnectionStorageManagerFactory.java | 3 +-- .../docker/ui/testutils/swt/SWTUtils.java | 16 +++++------ .../views/DockerExplorerViewSWTBotTest.java | 5 ++-- .../DockerImageHierarchyViewSWTBotTest.java | 6 ++--- .../docker/ui/commands/CommandUtils.java | 23 ++++++++-------- .../docker/ui/jobs/CopyFromDockerJob.java | 8 +++--- .../ui/wizards/ImageTagSelectionPage.java | 9 +++---- .../ui/wizards/NewDockerConnectionPage.java | 19 +++++++------ 14 files changed, 68 insertions(+), 81 deletions(-) diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/AbstractRegistry.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/AbstractRegistry.java index 7655a97a76..664c560c76 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/AbstractRegistry.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/AbstractRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2020 Red Hat. + * Copyright (c) 2016, 2023 Red Hat. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -151,13 +151,13 @@ public List getImages(String term) } List tmp = cisr.getRepositories().stream() .filter(e -> e.name().contains(term)) - .collect(Collectors.toList()); + .toList(); result.addAll(tmp.stream() .map(r -> new DockerImageSearchResult(r.description(), r.official(), r.automated(), r.name(), r.starCount())) - .collect(Collectors.toList())); + .toList()); } else { ImageSearchResultV1 pisr = null; final GenericType IMAGE_SEARCH_RESULT_LIST = new GenericType<>() { @@ -178,7 +178,7 @@ public List getImages(String term) .map(r -> new DockerImageSearchResult( r.description(), r.official(), r.automated(), r.name(), r.starCount())) - .collect(Collectors.toList())); + .toList()); } } catch (InterruptedException | ExecutionException e) { throw new DockerException(e); diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/DockerConnectionManager.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/DockerConnectionManager.java index d1b2fa84d9..fcce5ab374 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/DockerConnectionManager.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/DockerConnectionManager.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2014, 2018 Red Hat. - * + * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -14,7 +14,6 @@ import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.core.runtime.ListenerList; import org.eclipse.linuxtools.docker.core.IDockerConnectionSettings.BindingType; @@ -200,7 +199,7 @@ public boolean hasConnections() { /** * Finds the {@link IDockerConnection} from the given {@code connectionName} - * + * * @param connectionName * the name of the connection to find * @return the {@link IDockerConnection} or null if none @@ -223,7 +222,7 @@ public IDockerConnection getConnectionByName( /** * Finds the {@link IDockerConnection} from the given {@code connectionUri} - * + * * @param connectionUri * the URI of the connection to find * @return the {@link IDockerConnection} or null if none @@ -258,11 +257,11 @@ public List getConnectionNames() { reloadThread = null; } return Collections.unmodifiableList(getAllConnections().stream() - .map(c -> c.getName()) + .map(IDockerConnection::getName) // making sure that no 'null' name is returned in the list of // connection names. .filter(n -> n != null) - .collect(Collectors.toList())); + .toList()); } public IDockerConnection findConnection(final String name) { @@ -287,7 +286,7 @@ public IDockerConnection findConnection(final String name) { /** * Adds the given connection and notifies all registered * {@link IDockerConnectionManagerListener} - * + * * @param dockerConnection * the connection to add */ @@ -307,7 +306,7 @@ public void addConnection( /** * Adds the given connection and notifies optionally all registered * {@link IDockerConnectionManagerListener} - * + * * @param dockerConnection * the connection to add * @param notifyListeners @@ -376,7 +375,7 @@ public void removeConnectionManagerListener( /** * Notifies all listeners that a change occurred on the given connection - * + * * @param connection * the connection that changed * @param type @@ -394,12 +393,12 @@ public void notifyListeners(final IDockerConnection connection, /** * Notifies all listeners that a change occurred on the given connection but * does nothing if DockerConnectionManager isn't instantiated - * + * * @param connection * the connection that changed * @param type * the type of change - * + * * @since 4.0 */ public static void instanceNotifyListeners( @@ -412,7 +411,7 @@ public static void instanceNotifyListeners( /** * Finds the default {@link IDockerConnectionSettings} - * + * * @return the default {@link IDockerConnectionSettings} or * null if nothing was found */ @@ -424,7 +423,7 @@ public IDockerConnectionSettings findDefaultConnectionSettings() { /** * Resolves the name of the Docker instance, given the * {@link IDockerConnectionSettings} - * + * * @param connectionSettings * the settings to use to connect * @return the name retrieved from the Docker instance or null @@ -439,7 +438,7 @@ public String resolveConnectionName( /** * Updates the given {@link IDockerConnection} with the given {@code name} * and {@code connectionSettings} - * + * * @param connection * the {@link IDockerConnection} to update * @param name diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/RepositoryTagV2.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/RepositoryTagV2.java index 7727c657e3..8254e4fdaa 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/RepositoryTagV2.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/RepositoryTagV2.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2016, 2018 Red Hat. - * + * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -25,7 +25,7 @@ /** * Binding for Repository Tag results from a Registry V2. - * + * * Currently the returned repo tag results lack the same degree of information * returned from the V1 registries. */ diff --git a/containers/org.eclipse.linuxtools.docker.reddeer/src/org/eclipse/linuxtools/docker/reddeer/requirements/CleanDockerExplorerRequirement.java b/containers/org.eclipse.linuxtools.docker.reddeer/src/org/eclipse/linuxtools/docker/reddeer/requirements/CleanDockerExplorerRequirement.java index 5590ed0b32..5f7c9c61f9 100644 --- a/containers/org.eclipse.linuxtools.docker.reddeer/src/org/eclipse/linuxtools/docker/reddeer/requirements/CleanDockerExplorerRequirement.java +++ b/containers/org.eclipse.linuxtools.docker.reddeer/src/org/eclipse/linuxtools/docker/reddeer/requirements/CleanDockerExplorerRequirement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Red Hat, Inc. + * Copyright (c) 2018, 2023 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -18,7 +18,6 @@ import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.linuxtools.docker.reddeer.ui.DockerExplorerView; import org.eclipse.linuxtools.docker.reddeer.ui.resources.DockerConnection; @@ -87,7 +86,7 @@ public List getDockerConnections() { try { return new DefaultTree().getItems().stream() .map(x -> new DockerConnection(x)) - .collect(Collectors.toList()); + .toList(); } catch (CoreLayerException coreExc) { // there is no item in docker explorer } diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/docker/core/CopyFromDockerJobTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/docker/core/CopyFromDockerJobTest.java index d1e2b9a81f..09b985604d 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/docker/core/CopyFromDockerJobTest.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/docker/core/CopyFromDockerJobTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Mathema. + * Copyright (c) 2022, 2023 Mathema and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; import java.util.Vector; -import java.util.stream.Collectors; import java.util.stream.IntStream; import org.assertj.core.api.Assertions; @@ -88,7 +87,7 @@ public void setConnection() { @After public void cleanTemp() throws IOException { - var paths = Files.walk(localTempWork).collect(Collectors.toList()); + var paths = Files.walk(localTempWork).toList(); // Must delete recursively Collections.reverse(paths); paths.stream().forEach(p -> p.toFile().delete()); @@ -101,7 +100,7 @@ private java.nio.file.Path stripTemp(java.nio.file.Path p) { } private List getTempLs() throws IOException { - var paths = Files.walk(localTempWork).sorted().collect(Collectors.toList()); + var paths = Files.walk(localTempWork).sorted().toList(); var sep = File.separatorChar; @@ -120,7 +119,7 @@ private List getTempLs() throws IOException { return "U " + sep + stripTemp(f); } - }).map(f -> f.replace(sep, '/')).collect(Collectors.toList()); + }).map(f -> f.replace(sep, '/')).toList(); } @@ -283,7 +282,7 @@ public void FolderFromImageMany() throws Exception { exp.add("D /"); exp.add("D /manyfiles"); var files = IntStream.range(1, 10001).mapToObj(n -> "/manyfiles/F" + n).sorted().map(f -> "R " + f) - .collect(Collectors.toList()); + .toList(); exp.addAll(files); Assertions.assertThat(getTempLs()).isEqualTo(exp); } @@ -296,7 +295,7 @@ public void MirrorFromImageMany() throws Exception { exp.addAll(List.of("D /", "R /.copyState", "R /.image_id", "D /test", "D /test/manyfiles")); var files = IntStream.range(1, 10001).mapToObj(n -> "/test/manyfiles/F" + n).sorted().map(f -> "R " + f) - .collect(Collectors.toList()); + .toList(); exp.addAll(files); Assertions.assertThat(getTempLs()).isEqualTo(exp); diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/core/DockerImageTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/core/DockerImageTest.java index 6be298c938..737ebae07d 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/core/DockerImageTest.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/core/DockerImageTest.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.assertj.core.data.MapEntry; import org.eclipse.linuxtools.docker.core.IDockerImage; @@ -139,7 +138,7 @@ public void shouldDuplicateImageByRepo() { final IDockerImage fooImage = MockDockerImageFactory.id("sha256:foo_image") .name("foo_image", "foo_image_alias:alias").build(); // when - final List result = DockerImage.duplicateImageByRepo(fooImage).collect(Collectors.toList()); + final List result = DockerImage.duplicateImageByRepo(fooImage).toList(); // then assertThat(result).hasSize(2); assertThat(result.get(0).id()).isEqualTo("sha256:foo_image"); diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionStorageManagerFactory.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionStorageManagerFactory.java index 82d033de0d..5c2f580c5c 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionStorageManagerFactory.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionStorageManagerFactory.java @@ -14,7 +14,6 @@ package org.eclipse.linuxtools.internal.docker.ui.testutils; import java.util.Collections; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.linuxtools.docker.core.IDockerConnection; @@ -36,7 +35,7 @@ public static IDockerConnectionStorageManager loadNone() { public static IDockerConnectionStorageManager providing(final IDockerConnection... mockedConnections) { final IDockerConnectionStorageManager connectionStorageManager = Mockito .mock(IDockerConnectionStorageManager.class); - Mockito.when(connectionStorageManager.loadConnections()).thenReturn(Stream.of(mockedConnections).collect(Collectors.toList())); + Mockito.when(connectionStorageManager.loadConnections()).thenReturn(Stream.of(mockedConnections).toList()); return connectionStorageManager; } diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java index 83bfbd2646..c58ea4c346 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 Red Hat Inc. and others. + * Copyright (c) 2016, 2023 Red Hat Inc. and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -264,7 +264,7 @@ public static SWTBotTreeItem getTreeItem(final SWTBotTreeItem parentTreeItem, fi private static SWTBotTreeItem getTreeItem(final SWTBotTreeItem[] treeItems, final String[] paths) { final SWTBotTreeItem swtBotTreeItem = Stream.of(treeItems).filter(item -> item.getText().startsWith(paths[0])) .findFirst().orElseThrow(() -> new RuntimeException("Only available items: " - + Stream.of(treeItems).map(item -> item.getText()).collect(Collectors.joining(", ")))); + + Stream.of(treeItems).map(SWTBotTreeItem::getText).collect(Collectors.joining(", ")))); if (paths.length > 1) { syncExec(() -> swtBotTreeItem.expand()); final String[] remainingPath = new String[paths.length - 1]; @@ -276,10 +276,8 @@ private static SWTBotTreeItem getTreeItem(final SWTBotTreeItem[] treeItems, fina public static SWTBotTableItem getListItem(final SWTBotTable table, final String name) { return Stream.iterate(0, i -> i + 1).limit(table.rowCount()).map(rowNumber -> table.getTableItem(rowNumber)) - .filter(rowItem -> { - return Stream.iterate(0, j -> j + 1).limit(table.columnCount()) - .map(colNum -> rowItem.getText(colNum)).anyMatch(colValue -> colValue.contains(name)); - }).findFirst().orElse(null); + .filter(rowItem -> Stream.iterate(0, j -> j + 1).limit(table.columnCount()) + .map(colNum -> rowItem.getText(colNum)).anyMatch(colValue -> colValue.contains(name))).findFirst().orElse(null); } /** @@ -312,7 +310,7 @@ public static void wait(final int duration, final TimeUnit unit) { public static SWTBotTreeItem select(final SWTBotTreeItem parentTreeItem, final String... matchItems) { final List fullyQualifiedItems = Stream.of(parentTreeItem.getItems()).filter( treeItem -> Stream.of(matchItems).anyMatch(matchItem -> treeItem.getText().startsWith(matchItem))) - .map(item -> item.getText()).collect(Collectors.toList()); + .map(SWTBotTreeItem::getText).toList(); return parentTreeItem.select(fullyQualifiedItems.toArray(new String[0])); } @@ -330,7 +328,7 @@ public static SWTBotTreeItem select(final SWTBotTreeItem parentTreeItem, final S public static SWTBotTree select(final SWTBotTree parentTree, final String... matchItems) { final List fullyQualifiedItems = Stream.of(parentTree.getAllItems()).filter( treeItem -> Stream.of(matchItems).anyMatch(matchItem -> treeItem.getText().startsWith(matchItem))) - .map(item -> item.getText()).collect(Collectors.toList()); + .map(SWTBotTreeItem::getText).toList(); return parentTree.select(fullyQualifiedItems.toArray(new String[0])); } @@ -500,7 +498,7 @@ public static SWTBotToolbarButton getConsoleToolbarButtonWithTooltipText(final S } public static void closeView(final SWTWorkbenchBot bot, final String viewId) { - bot.views().stream().filter(v -> v.getReference().getId().equals(viewId)).forEach(v -> v.close()); + bot.views().stream().filter(v -> v.getReference().getId().equals(viewId)).forEach(SWTBotView::close); } /** diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java index b6505026a7..13c9005e5a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.assertj.core.api.Assertions; @@ -641,14 +640,14 @@ public void shouldRemoveAllConnectionsSimultaneously() { .withDefaultTCPConnectionSettings(); DockerConnectionManagerUtils.configureConnectionManager(dockerConnection1, dockerConnection2); final List initialConnections = Stream.of(dockerExplorerViewBot.bot().tree().getAllItems()) - .map(SWTBotTreeItem::getText).collect(Collectors.toList()); + .map(SWTBotTreeItem::getText).toList(); assertThat(initialConnections).contains("Test1", "Test2"); // when SWTUtils.select(dockerExplorerViewBot.bot().tree(), "Test1", "Test2"); SWTUtils.getContextMenu(dockerExplorerViewBot.bot().tree(), "Remove").click(); // then final List remainingConnections = Stream.of(dockerExplorerViewBot.bot().tree().getAllItems()) - .map(SWTBotTreeItem::getText).collect(Collectors.toList()); + .map(SWTBotTreeItem::getText).toList(); assertThat(remainingConnections).doesNotContain("Test1", "Test2"); } diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImageHierarchyViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImageHierarchyViewSWTBotTest.java index 17b2791be3..8273b4b69b 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImageHierarchyViewSWTBotTest.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImageHierarchyViewSWTBotTest.java @@ -16,7 +16,6 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.linuxtools.docker.core.IDockerContainer; import org.eclipse.linuxtools.docker.core.IDockerImage; @@ -48,7 +47,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; - import org.mandas.docker.client.DockerClient; import org.mandas.docker.client.messages.Container; import org.mandas.docker.client.messages.Image; @@ -88,7 +86,7 @@ public void setupViews() { this.dockerExplorerViewBot = bot.viewById(DockerExplorerView.VIEW_ID); // make sure that the Docker Image Hierarchy view is closed this.bot.views().stream().filter(v -> v.getReference().getId().equals(DockerImageHierarchyView.VIEW_ID)) - .forEach(v -> v.close()); + .forEach(SWTBotView::close); } @Before @@ -145,7 +143,7 @@ private List getChildrenElementIds(final IDockerImageHierarchyNode fooIm return ((IDockerImage) e.getElement()).id(); } return ((IDockerContainer) e.getElement()).id(); - }).collect(Collectors.toList()); + }).toList(); } private DockerImageHierarchyView getDockerImageHierarchyView() { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java index 0343ca1865..1cad56bc3a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java @@ -1,6 +1,6 @@ /******************************************************************************* - * Copyright (c) 2014, 2018 Red Hat Inc. and others. - * + * Copyright (c) 2014, 2023 Red Hat Inc. and others. + * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -15,7 +15,6 @@ import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.core.commands.Command; @@ -59,7 +58,7 @@ public class CommandUtils { /** * Refreshes (async) the {@link Viewer}. - * + * * @param viewer * - the {@link Viewer} to refresh */ @@ -213,7 +212,7 @@ public static IDockerImage getSelectedImage( /** * Returns the given {@link List} typed with the given * {@code targetClass}. - * + * * @param selection * the current selection * @return Returns the given {@link List} typed with the @@ -222,17 +221,17 @@ public static IDockerImage getSelectedImage( @SuppressWarnings("unchecked") private static List castSelectionTo( final IStructuredSelection selection, final Class targetClass) { - return (List) selection.toList().stream() + return selection.toList().stream() .filter(selectedElement -> targetClass .isAssignableFrom(selectedElement.getClass())) .map(selectedElement -> (T) selectedElement) - .collect(Collectors.toList()); + .toList(); } /** * Returns the given {@link List} adapted to the given * {@code targetClass}. - * + * * @param selection * the current selection * @param targetClass @@ -253,7 +252,7 @@ private static List adaptSelectionTo( /** * Finds and returns a cleared {@link RunConsole} if the preference * {@link PreferenceConstants#AUTOLOG_ON_START} is set to {@code true}. - * + * * @param connection * the current Docker connection * @param container @@ -289,7 +288,7 @@ public static RunConsole getRunConsole(final IDockerConnection connection, final /** * Opens the given {@link IWizard} and returns true if the user * finished the operation, false if he cancelled it. - * + * * @param wizard * the wizard to open * @param shell @@ -306,7 +305,7 @@ public static boolean openWizard(final IWizard wizard, final Shell shell) { /** * Opens the given {@link IWizard} and returns true if the user * finished the operation, false if he cancelled it. - * + * * @param wizard * the wizard to open * @param shell @@ -329,7 +328,7 @@ public static boolean openWizard(final IWizard wizard, final Shell shell, /** * Executes the command identified by the given {@code id} on a context * based on the given selection - * + * * @param id * the id of the command to execute * @param selection diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/CopyFromDockerJob.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/CopyFromDockerJob.java index 733b3dd377..f5c4a34a49 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/CopyFromDockerJob.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/CopyFromDockerJob.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2021 Red Hat Inc. and others + * Copyright (c) 2021, 2023 Red Hat Inc. and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -857,7 +857,7 @@ private void initmirror() throws FileNotFoundException, IOException, Interrupted } // Delete old files if (m_targetfolder.toFile().exists()) { - var paths = Files.walk(m_targetfolder.toFile().toPath()).collect(Collectors.toList()); + var paths = Files.walk(m_targetfolder.toFile().toPath()).toList(); Collections.reverse(paths); paths.stream().forEach(p -> p.toFile().delete()); } @@ -948,12 +948,12 @@ private boolean needsBeingCopied(Path sourcePath, boolean addToCopyingList, bool // Check if another job copies something including sourcePath - this may also be // sourcePath jAbove = m_copyingMap.entrySet().stream().filter(other -> other.getKey().isPrefixOf(sourcePath)) - .map(Map.Entry::getValue).collect(Collectors.toList()); + .map(Map.Entry::getValue).toList(); // Check if some other job copies something sourcePath includes - this may also // be sourcePath jBelow = m_copyingMap.entrySet().stream().filter(other -> sourcePath.isPrefixOf(other.getKey())) - .map(Map.Entry::getValue).collect(Collectors.toList()); + .map(Map.Entry::getValue).toList(); if (jAbove.isEmpty() && !wascopied) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageTagSelectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageTagSelectionPage.java index 7d388ca353..5989657fa4 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageTagSelectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageTagSelectionPage.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2015, 2018 Red Hat Inc. and others. - * + * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -20,7 +20,6 @@ import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.typed.BeanProperties; @@ -62,7 +61,7 @@ public class ImageTagSelectionPage extends WizardPage { /** * Default constructor. - * + * * @param model * the model associated to this page * @param registry @@ -105,7 +104,7 @@ private void searchTags() { final List tags = repositoryTags .stream() .map(c -> (RepositoryTag) c) - .collect(Collectors.toList()); + .toList(); Collections.sort(tags); monitor.worked(1); final IDockerConnection connection = model @@ -117,7 +116,7 @@ private void searchTags() { connection.hasImage( selectedImageName, t.getName()))) - .collect(Collectors.toList()); + .toList(); monitor.worked(1); searchResultQueue.offer(searchResults); } catch (DockerException e) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java index fadf5e873f..47c117dc9a 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java @@ -82,7 +82,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ListDialog; import org.eclipse.ui.dialogs.PreferencesUtil; - import org.mandas.docker.client.exceptions.DockerCertificateException; /** @@ -161,7 +160,7 @@ public void dispose() { /** * Creates the connection settings container, where the user can choose how * to connect to the docker daemon (using sockets or TCP with SSL - or not) - * + * * @param parent * the parent container (ie, the main container in the preference * page) @@ -595,7 +594,7 @@ private void setWidgetsEnabled(final boolean enabled, /** * Verifies that the given connection settings work by trying to connect to * the target Docker daemon - * + * * @return */ private SelectionListener onTestConnectionButtonSelection() { @@ -693,11 +692,11 @@ public void widgetSelected(SelectionEvent e) { dockerMachineInstallDir, vmDriverInstallDir); final List activeMachineNames = allMachineStates .entrySet().stream() - .filter((machineEntry) -> machineEntry.getValue() + .filter(machineEntry -> machineEntry.getValue() .booleanValue()) - .map((machineEntry) -> machineEntry.getKey()) - .collect(Collectors.toList()); - if (activeMachineNames.size() > 0) { + .map(machineEntry -> machineEntry.getKey()) + .toList(); + if (!activeMachineNames.isEmpty()) { ListDialog connPrompt = new ListDialog(getShell()); connPrompt.setContentProvider( new ConnectionSelectionContentProvider()); @@ -774,7 +773,7 @@ public void widgetSelected(SelectionEvent e) { * Verifies that the install dirs for Docker Machine and its driver * are valid, otherwise offers to open the preference page to fix * the settings. - * + * * @return true if the settings are valid, * false otherwise. */ @@ -821,7 +820,7 @@ private boolean validDockerMachineInstallDirs() { /** * Retrieves the docker machine names along with a boolean flag to * indicate if it is running or not. - * + * * @param dockerMachineInstallDir * @param vmDriverInstallDir * @return @@ -855,7 +854,7 @@ private Map retrieveDockerMachineNames( /** * Opens a new {@link DockerConnection} using the settings of this * {@link NewDockerConnectionPage}. - * + * * @return * @throws DockerCertificateException */