From e5e3dd235d572956d49ea461346466d54aec7195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 24 Mar 2024 12:01:08 +0100 Subject: [PATCH] code simplifications --- .../maven/tools/plugin/util/PluginUtils.java | 17 ++--------------- .../tools/plugin/generator/GeneratorUtils.java | 9 +++++---- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java index 98b764bb..55ea5f9e 100644 --- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java +++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java @@ -23,7 +23,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -85,13 +84,7 @@ public static String[] findSources(String basedir, String include, String exclud */ public static void sortMojos(List mojoDescriptors) { if (mojoDescriptors != null) { - Collections.sort(mojoDescriptors, new Comparator() { - /** {@inheritDoc} */ - @Override - public int compare(MojoDescriptor mojo0, MojoDescriptor mojo1) { - return mojo0.getGoal().compareToIgnoreCase(mojo1.getGoal()); - } - }); + mojoDescriptors.sort(Comparator.comparing(MojoDescriptor::getGoal)); } } @@ -104,13 +97,7 @@ public int compare(MojoDescriptor mojo0, MojoDescriptor mojo1) { */ public static void sortMojoParameters(List parameters) { if (parameters != null) { - Collections.sort(parameters, new Comparator() { - /** {@inheritDoc} */ - @Override - public int compare(Parameter parameter1, Parameter parameter2) { - return parameter1.getName().compareToIgnoreCase(parameter2.getName()); - } - }); + parameters.sort(Comparator.comparing(Parameter::getName)); } } diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java index c9779870..ff27c17e 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java @@ -33,6 +33,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -178,9 +179,9 @@ static String decodeJavadocTags(String description) { while (matcher.find()) { String tag = matcher.group(1); String text = matcher.group(2); - text = StringUtils.replace(text, "&", "&"); - text = StringUtils.replace(text, "<", "<"); - text = StringUtils.replace(text, ">", ">"); + text = text.replace("&", "&"); + text = text.replace("<", "<"); + text = text.replace(">", ">"); if ("code".equals(tag)) { text = "" + text + ""; } else if ("link".equals(tag) || "linkplain".equals(tag) || "value".equals(tag)) { @@ -516,7 +517,7 @@ public static String discoverPackageName(PluginDescriptor pluginDescriptor) { for (MojoDescriptor descriptor : mojoDescriptors) { String impl = descriptor.getImplementation(); - if (StringUtils.equals(descriptor.getGoal(), "help") && StringUtils.equals("HelpMojo", impl)) { + if (Objects.equals(descriptor.getGoal(), "help") && Objects.equals("HelpMojo", impl)) { continue; } if (impl.lastIndexOf('.') != -1) {