You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2022/01/15 17:34:59 UTC
[maven-dist-tool] branch master updated: Improved code.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dist-tool.git
The following commit(s) were added to refs/heads/master by this push:
new 5a72d2b Improved code.
5a72d2b is described below
commit 5a72d2b83323c3cb590f6922d28cde475ffa679e
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sat Jan 15 18:34:54 2022 +0100
Improved code.
---
.../dist/tools/prerequisites/GetPrerequisites.java | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java b/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java
index 0ddb433..0e337e6 100644
--- a/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java
+++ b/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java
@@ -21,9 +21,9 @@ package org.apache.maven.dist.tools.prerequisites;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.dist.tools.JsoupRetry;
@@ -154,7 +154,7 @@ public class GetPrerequisites
public List<PluginPrerequisites> getPrequisites()
{
- List<PluginPrerequisites> result = new ArrayList<PluginPrerequisites>();
+ List<PluginPrerequisites> result = new ArrayList<>();
for ( String pluginName : PLUGIN_NAMES )
{
@@ -173,17 +173,7 @@ public class GetPrerequisites
public Map<ArtifactVersion, List<PluginPrerequisites>> getGroupedPrequisites()
{
- Map<ArtifactVersion, List<PluginPrerequisites>> result = new HashMap<>();
-
- for ( PluginPrerequisites pluginPrerequisites : getPrequisites() )
- {
- if ( !result.containsKey( pluginPrerequisites.getMavenVersion() ) )
- {
- result.put( pluginPrerequisites.getMavenVersion(), new ArrayList<>() );
- }
- result.get( pluginPrerequisites.getMavenVersion() ).add( pluginPrerequisites );
- }
-
- return result;
+ return getPrequisites().stream()
+ .collect( Collectors.groupingBy( PluginPrerequisites::getMavenVersion ) );
}
}