Skip to content

Commit

Permalink
reduce usage of Guava
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 10, 2024
1 parent d28d37d commit bbd120f
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private List<String> getPostProcessorValidators() {
return (List<String>)validators;
}
else {
return ImmutableList.of();
return List.of();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static List<URL> getEnvironmentClasspathUrls(List<String> dependencyUrls,
List<URL> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final Void apply(FileContext file, FileHeaderContext context) {

List<String> sanitizedCommentLines;
if (context.getCommentLines() == null) {
sanitizedCommentLines = ImmutableList.of();
sanitizedCommentLines = List.of();
}
else {
sanitizedCommentLines = context.getCommentLines().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -50,7 +50,7 @@ public class JsonEscapingStrategy implements EscapingStrategyPlugin {
private static final CharSequenceTranslator ESCAPE_JSON =
new AggregateTranslator(
new LookupTranslator(
ImmutableMap.of(
Map.of(
"\"", "\\\"",
"\\", "\\\\"
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -64,7 +62,7 @@ public String getValueProviderName() {
public Object getValueProviderConfig(String key) {
Map<String, Object> config = valueProviderGlobalContext.getValueProviderConfig(valueProviderName);
if (config == null) {
config = ImmutableMap.of();
config = Map.of();
}
return config.get(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

import org.yaml.snakeyaml.Yaml;

import com.google.common.collect.ImmutableSet;

import io.wcm.devops.conga.resource.Resource;

/**
Expand All @@ -38,7 +36,7 @@
public abstract class AbstractModelReader<T> implements ModelReader<T> {

private static final String YAML_EXTENSION = "yaml";
private static final Set<String> SUPPORTED_EXTENSIONS = ImmutableSet.of(YAML_EXTENSION);
private static final Set<String> SUPPORTED_EXTENSIONS = Set.of(YAML_EXTENSION);

private final Yaml yaml;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -172,7 +171,7 @@ abstract class AbstractCongaMojo extends AbstractMojo {
@Component
protected MavenProjectHelper projectHelper;

private static final Map<String, String> DEFAULT_ARTIFACT_TYPE_MAPPINGS = ImmutableMap.of(
private static final Map<String, String> DEFAULT_ARTIFACT_TYPE_MAPPINGS = Map.of(
"bundle", "jar",
"content-package", "zip");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ private <T> List<T> validateFiles(ResourceCollection sourceDir, ResourceCollecti
private <T> List<T> validateFiles(ResourceCollection sourceDir, ResourceCollection rootSourceDir, DefinitionValidator<T> validator,
Function<ResourceInfo, Boolean> resourceFilter) throws MojoFailureException {
if (!sourceDir.exists()) {
return ImmutableList.of();
return List.of();
}
SortedSet<Resource> files = sourceDir.getResources();
SortedSet<ResourceCollection> dirs = sourceDir.getResourceCollections();
if (files.isEmpty() && dirs.isEmpty()) {
return ImmutableList.of();
return List.of();
}

List<T> result = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit bbd120f

Please sign in to comment.