From bbd120fd0acf36555f137b39ca6c5328fb1ee70b Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 10 Jan 2024 13:22:51 +0100 Subject: [PATCH] reduce usage of Guava --- .../io/wcm/devops/conga/generator/EnvironmentGenerator.java | 2 +- .../java/io/wcm/devops/conga/generator/FileGenerator.java | 2 +- .../io/wcm/devops/conga/generator/ResourceLoaderUtil.java | 2 +- .../generator/plugins/fileheader/AbstractFileHeader.java | 2 +- .../plugins/handlebars/escaping/JsonEscapingStrategy.java | 6 +++--- .../conga/generator/spi/context/ValueProviderContext.java | 4 +--- .../conga/generator/util/ConfigInheritanceResolver.java | 4 +--- .../devops/conga/generator/util/EnvironmentExpander.java | 4 +--- .../wcm/devops/conga/model/reader/AbstractModelReader.java | 4 +--- .../conga/tooling/maven/plugin/AbstractCongaMojo.java | 3 +-- .../wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java | 4 ++-- .../conga/tooling/maven/plugin/util/ClassLoaderUtil.java | 5 ++--- .../tooling/maven/plugin/util/MavenArtifactHelper.java | 4 +--- 13 files changed, 17 insertions(+), 29 deletions(-) diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java b/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java index 4f60920e..f4685568 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java @@ -158,7 +158,7 @@ class EnvironmentGenerator { ContextPropertiesBuilder.buildEnvironmentContextVariables(environmentName, this.environment, options.getVersion(), variableObjectTreeResolver, variableStringResolver)); - this.dependencyVersions = options.getDependencyVersionBuilder() != null ? options.getDependencyVersionBuilder().apply(environment) : ImmutableList.of(); + this.dependencyVersions = options.getDependencyVersionBuilder() != null ? options.getDependencyVersionBuilder().apply(environment) : List.of(); // prepare YAML representer yamlRepresenter = new YamlRepresenter(); diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java b/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java index e21aac75..e77cfe85 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java @@ -510,7 +510,7 @@ private List getPostProcessorValidators() { return (List)validators; } else { - return ImmutableList.of(); + return List.of(); } } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java b/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java index f27034da..635a12e7 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java @@ -79,7 +79,7 @@ public static List getEnvironmentClasspathUrls(List dependencyUrls, List classpathUrls = new ArrayList<>(); for (String dependencyUrl : dependencyUrls) { // resolver variables without config map - thus supporting only value providers with external values - String resolvedDependencyUrl = variableStringResolver.resolveString(dependencyUrl, ImmutableMap.of()); + String resolvedDependencyUrl = variableStringResolver.resolveString(dependencyUrl, Map.of()); try { classpathUrls.addAll(urlFileManager.getFileUrlsWithDependencies(resolvedDependencyUrl)); } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java index e152674c..95a01b08 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java @@ -50,7 +50,7 @@ public final Void apply(FileContext file, FileHeaderContext context) { List sanitizedCommentLines; if (context.getCommentLines() == null) { - sanitizedCommentLines = ImmutableList.of(); + sanitizedCommentLines = List.of(); } else { sanitizedCommentLines = context.getCommentLines().stream() diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/escaping/JsonEscapingStrategy.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/escaping/JsonEscapingStrategy.java index 2cf91647..985abfdc 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/escaping/JsonEscapingStrategy.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/escaping/JsonEscapingStrategy.java @@ -19,13 +19,13 @@ */ package io.wcm.devops.conga.generator.plugins.handlebars.escaping; +import java.util.Map; + import org.apache.commons.text.translate.AggregateTranslator; import org.apache.commons.text.translate.CharSequenceTranslator; import org.apache.commons.text.translate.EntityArrays; import org.apache.commons.text.translate.LookupTranslator; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin; import io.wcm.devops.conga.generator.spi.handlebars.context.EscapingStrategyContext; import io.wcm.devops.conga.generator.util.FileUtil; @@ -50,7 +50,7 @@ public class JsonEscapingStrategy implements EscapingStrategyPlugin { private static final CharSequenceTranslator ESCAPE_JSON = new AggregateTranslator( new LookupTranslator( - ImmutableMap.of( + Map.of( "\"", "\\\"", "\\", "\\\\" )), diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/spi/context/ValueProviderContext.java b/generator/src/main/java/io/wcm/devops/conga/generator/spi/context/ValueProviderContext.java index f292d9b1..8e0c8378 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/spi/context/ValueProviderContext.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/spi/context/ValueProviderContext.java @@ -21,8 +21,6 @@ import java.util.Map; -import com.google.common.collect.ImmutableMap; - /** * Context for a single {@link io.wcm.devops.conga.generator.spi.ValueProviderPlugin} instance. */ @@ -64,7 +62,7 @@ public String getValueProviderName() { public Object getValueProviderConfig(String key) { Map config = valueProviderGlobalContext.getValueProviderConfig(valueProviderName); if (config == null) { - config = ImmutableMap.of(); + config = Map.of(); } return config.get(key); } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolver.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolver.java index 325f58b6..d467dce1 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolver.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolver.java @@ -26,8 +26,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableSet; - import io.wcm.devops.conga.model.environment.Environment; import io.wcm.devops.conga.model.environment.Node; import io.wcm.devops.conga.model.environment.NodeRole; @@ -67,7 +65,7 @@ public static void resolve(Object model) { } if (model instanceof Role) { // do not inherit config of role variants field (WDCONGA-24) - ignorePropertyNames = ImmutableSet.of("variants"); + ignorePropertyNames = Set.of("variants"); } new ConfigInheritanceResolver(ignorePropertyNames).process(model, PROCESSOR, new HashMap<>()); } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/EnvironmentExpander.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/EnvironmentExpander.java index ad70dbec..06179683 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/EnvironmentExpander.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/EnvironmentExpander.java @@ -26,8 +26,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.model.environment.Environment; import io.wcm.devops.conga.model.environment.Node; @@ -77,7 +75,7 @@ else if (hasNodes) { for (String nodeName : node.getNodes()) { Node clonedNode = ObjectCloner.deepClone(node); clonedNode.setNode(nodeName); - clonedNode.setNodes(ImmutableList.of()); + clonedNode.setNodes(List.of()); nodes.add(clonedNode); } } diff --git a/model/src/main/java/io/wcm/devops/conga/model/reader/AbstractModelReader.java b/model/src/main/java/io/wcm/devops/conga/model/reader/AbstractModelReader.java index 4ee1be33..a1785a9b 100644 --- a/model/src/main/java/io/wcm/devops/conga/model/reader/AbstractModelReader.java +++ b/model/src/main/java/io/wcm/devops/conga/model/reader/AbstractModelReader.java @@ -28,8 +28,6 @@ import org.yaml.snakeyaml.Yaml; -import com.google.common.collect.ImmutableSet; - import io.wcm.devops.conga.resource.Resource; /** @@ -38,7 +36,7 @@ public abstract class AbstractModelReader implements ModelReader { private static final String YAML_EXTENSION = "yaml"; - private static final Set SUPPORTED_EXTENSIONS = ImmutableSet.of(YAML_EXTENSION); + private static final Set SUPPORTED_EXTENSIONS = Set.of(YAML_EXTENSION); private final Yaml yaml; diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java index faf38c3a..92e66a45 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java @@ -54,7 +54,6 @@ import org.codehaus.plexus.archiver.jar.ManifestException; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.export.ModelExport; @@ -172,7 +171,7 @@ abstract class AbstractCongaMojo extends AbstractMojo { @Component protected MavenProjectHelper projectHelper; - private static final Map DEFAULT_ARTIFACT_TYPE_MAPPINGS = ImmutableMap.of( + private static final Map DEFAULT_ARTIFACT_TYPE_MAPPINGS = Map.of( "bundle", "jar", "content-package", "zip"); diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java index eeb6080e..d89262f5 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java @@ -204,12 +204,12 @@ private List validateFiles(ResourceCollection sourceDir, ResourceCollecti private List validateFiles(ResourceCollection sourceDir, ResourceCollection rootSourceDir, DefinitionValidator validator, Function resourceFilter) throws MojoFailureException { if (!sourceDir.exists()) { - return ImmutableList.of(); + return List.of(); } SortedSet files = sourceDir.getResources(); SortedSet dirs = sourceDir.getResourceCollections(); if (files.isEmpty() && dirs.isEmpty()) { - return ImmutableList.of(); + return List.of(); } List result = new ArrayList<>(); diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/ClassLoaderUtil.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/ClassLoaderUtil.java index 2498e331..a025b708 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/ClassLoaderUtil.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/ClassLoaderUtil.java @@ -25,14 +25,13 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.model.Resource; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import com.google.common.collect.ImmutableMap; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -94,7 +93,7 @@ public static String resolveDependencyUrl(String dependencyUrl, PluginContextOpt VariableStringResolver variableStringResolver = new VariableStringResolver(valueProviderGlobalContext, variableMapResolver); // resolver variables without config map - thus supporting only value providers with external values - return variableStringResolver.resolveString(dependencyUrl, ImmutableMap.of()); + return variableStringResolver.resolveString(dependencyUrl, Map.of()); } } diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/MavenArtifactHelper.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/MavenArtifactHelper.java index 3924a1ef..650bb03a 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/MavenArtifactHelper.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/util/MavenArtifactHelper.java @@ -45,8 +45,6 @@ import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.model.environment.Environment; import io.wcm.devops.conga.tooling.maven.plugin.urlfile.MavenUrlFilePlugin; @@ -75,7 +73,7 @@ public MavenArtifactHelper(Environment environment, PluginContextOptions pluginC this.repoSession = mavenContext.getRepoSession(); this.remoteRepos = mavenContext.getRemoteRepos(); this.artifactTypeMappings = mavenContext.getArtifactTypeMappings(); - this.environmentDependencyUrls = environment != null ? environment.getDependencies() : ImmutableList.of(); + this.environmentDependencyUrls = environment != null ? environment.getDependencies() : List.of(); this.pluginContextOptions = pluginContextOptions; }