[MNG-6847] Use diamond operator (#153)
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.UseDiamondOperator?organizationId=QXBhY2hlIE1hdmVu
Co-authored-by: Moderne <team@moderne.io>
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
index b2f0388..1def909 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
@@ -155,13 +155,13 @@
@Override
public Assembly getAssemblyForDescriptorReference(final String ref, final AssemblerConfigurationSource configSource)
throws AssemblyReadException, InvalidAssemblerConfigurationException {
- return addAssemblyForDescriptorReference(ref, configSource, new ArrayList<Assembly>(1));
+ return addAssemblyForDescriptorReference(ref, configSource, new ArrayList<>(1));
}
@Override
public Assembly getAssemblyFromDescriptorFile(final File file, final AssemblerConfigurationSource configSource)
throws AssemblyReadException, InvalidAssemblerConfigurationException {
- return addAssemblyFromDescriptorFile(file, configSource, new ArrayList<Assembly>(1));
+ return addAssemblyFromDescriptorFile(file, configSource, new ArrayList<>(1));
}
private Assembly addAssemblyForDescriptorReference(
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
index de354f4..fbf2671 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
@@ -30,7 +30,7 @@
*/
class DefaultMessageHolder implements MessageHolder {
- private List<Message> messages = new ArrayList<Message>();
+ private List<Message> messages = new ArrayList<>();
private Message currentMessage;
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/Locator.java b/src/main/java/org/apache/maven/plugins/assembly/io/Locator.java
index 27ffb30..9904774 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/Locator.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/Locator.java
@@ -37,7 +37,7 @@
*/
Locator(List<LocatorStrategy> strategies, MessageHolder messageHolder) {
this.messageHolder = messageHolder;
- this.strategies = new ArrayList<LocatorStrategy>(strategies);
+ this.strategies = new ArrayList<>(strategies);
}
/**
@@ -45,7 +45,7 @@
*/
Locator() {
this.messageHolder = new DefaultMessageHolder();
- this.strategies = new ArrayList<LocatorStrategy>();
+ this.strategies = new ArrayList<>();
}
/**
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/MessageLevels.java b/src/main/java/org/apache/maven/plugins/assembly/io/MessageLevels.java
index 1e36729..66be82e 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/MessageLevels.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/MessageLevels.java
@@ -56,7 +56,7 @@
private static final List<String> LEVEL_NAMES;
static {
- List<String> names = new ArrayList<String>();
+ List<String> names = new ArrayList<>();
names.add("DEBUG");
names.add("INFO");
names.add("WARN");
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
index 47bfcb7..825e500 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
-import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Model;
@@ -87,7 +86,7 @@
project.setArtifacts(Collections.singleton(artifact));
when(dependencyResolver.resolveDependencySets(eq(assembly), isNull(), anyList()))
- .thenReturn(new LinkedHashMap<DependencySet, Set<Artifact>>());
+ .thenReturn(new LinkedHashMap<>());
this.phase.execute(assembly, null, null);
@@ -102,7 +101,7 @@
assembly.setIncludeBaseDirectory(false);
when(dependencyResolver.resolveDependencySets(eq(assembly), isNull(), anyList()))
- .thenReturn(new LinkedHashMap<DependencySet, Set<Artifact>>());
+ .thenReturn(new LinkedHashMap<>());
this.phase.execute(assembly, null, null);
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
index b96239b..915e1f2 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
@@ -35,7 +35,6 @@
import org.apache.maven.plugins.assembly.archive.DefaultAssemblyArchiverTest;
import org.apache.maven.plugins.assembly.artifact.DependencyResolver;
import org.apache.maven.plugins.assembly.model.Assembly;
-import org.apache.maven.plugins.assembly.model.DependencySet;
import org.apache.maven.plugins.assembly.model.FileSet;
import org.apache.maven.plugins.assembly.model.ModuleBinaries;
import org.apache.maven.plugins.assembly.model.ModuleSet;
@@ -284,7 +283,7 @@
assembly.addModuleSet(ms);
when(dependencyResolver.resolveDependencySets(eq(assembly), eq(ms), eq(configSource), anyList()))
- .thenReturn(new LinkedHashMap<DependencySet, Set<Artifact>>());
+ .thenReturn(new LinkedHashMap<>());
DefaultAssemblyArchiverTest.setupInterpolators(configSource, module);
this.phase.execute(assembly, archiver, configSource);
@@ -360,7 +359,7 @@
final Set<MavenProject> projects = singleton(project);
when(dependencyResolver.resolveDependencySets(isNull(), isNull(), eq(configSource), anyList()))
- .thenReturn(new LinkedHashMap<DependencySet, Set<Artifact>>());
+ .thenReturn(new LinkedHashMap<>());
DefaultAssemblyArchiverTest.setupInterpolators(configSource, project);
this.phase.addModuleBinaries(null, null, binaries, projects, archiver, configSource);
@@ -442,7 +441,7 @@
when(dependencyResolver.resolveDependencySets(
isNull(), isNull(), any(AssemblerConfigurationSource.class), anyList()))
- .thenReturn(new LinkedHashMap<DependencySet, Set<Artifact>>());
+ .thenReturn(new LinkedHashMap<>());
DefaultAssemblyArchiverTest.setupInterpolators(configSource, project);
this.phase.addModuleBinaries(null, null, binaries, projects, archiver, configSource);
diff --git a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
index 77116fe..32c88eb 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
@@ -167,8 +167,8 @@
final Artifact pomArtifact = newArtifact(groupId, artifactId, version);
project.setArtifact(pomArtifact);
- project.setArtifacts(new HashSet<Artifact>());
- project.setDependencyArtifacts(new HashSet<Artifact>());
+ project.setArtifacts(new HashSet<>());
+ project.setDependencyArtifacts(new HashSet<>());
project.setFile(new File(basedir, "pom.xml"));