Skip to content

Commit 56a1e7c

Browse files
committed
Use List.of / Map.of / Set.of
1 parent 86a8345 commit 56a1e7c

File tree

116 files changed

+288
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+288
-406
lines changed

api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.maven.api.services;
2020

2121
import java.util.Collection;
22-
import java.util.Collections;
22+
import java.util.List;
2323

2424
import org.apache.maven.api.ProducedArtifact;
2525
import org.apache.maven.api.Service;
@@ -51,7 +51,7 @@ public interface ArtifactInstaller extends Service {
5151
* {@code artifact} is {@code null}
5252
*/
5353
default void install(Session session, ProducedArtifact artifact) {
54-
install(session, Collections.singletonList(artifact));
54+
install(session, List.of(artifact));
5555
}
5656

5757
/**

api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerRequest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.api.services;
2020

2121
import java.util.Collection;
22-
import java.util.Collections;
2322
import java.util.List;
2423
import java.util.Objects;
2524

@@ -62,7 +61,7 @@ static ArtifactInstallerRequest build(Session session, Collection<ProducedArtifa
6261
class ArtifactInstallerRequestBuilder {
6362
Session session;
6463
RequestTrace trace;
65-
Collection<ProducedArtifact> artifacts = Collections.emptyList();
64+
Collection<ProducedArtifact> artifacts = List.of();
6665

6766
ArtifactInstallerRequestBuilder() {}
6867

@@ -80,7 +79,7 @@ public ArtifactInstallerRequestBuilder trace(RequestTrace trace) {
8079

8180
@Nonnull
8281
public ArtifactInstallerRequestBuilder artifacts(@Nullable Collection<ProducedArtifact> artifacts) {
83-
this.artifacts = artifacts != null ? artifacts : Collections.emptyList();
82+
this.artifacts = artifacts != null ? artifacts : List.of();
8483
return this;
8584
}
8685

api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinatesFactoryRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import java.util.ArrayList;
2222
import java.util.Collection;
23-
import java.util.Collections;
23+
import java.util.List;
2424
import java.util.Objects;
2525

2626
import org.apache.maven.api.ArtifactCoordinates;
@@ -117,7 +117,7 @@ class DependencyCoordinatesFactoryRequestBuilder {
117117
private String coordinateString;
118118
private String scope;
119119
private boolean optional;
120-
private Collection<Exclusion> exclusions = Collections.emptyList();
120+
private Collection<Exclusion> exclusions = List.of();
121121

122122
DependencyCoordinatesFactoryRequestBuilder() {}
123123

api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyResolverRequest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.util.ArrayList;
2222
import java.util.Collection;
23-
import java.util.Collections;
2423
import java.util.List;
2524
import java.util.Objects;
2625
import java.util.Optional;
@@ -176,8 +175,8 @@ class DependencyResolverRequestBuilder {
176175
Project project;
177176
Artifact rootArtifact;
178177
DependencyCoordinates root;
179-
List<DependencyCoordinates> dependencies = Collections.emptyList();
180-
List<DependencyCoordinates> managedDependencies = Collections.emptyList();
178+
List<DependencyCoordinates> dependencies = List.of();
179+
List<DependencyCoordinates> managedDependencies = List.of();
181180
boolean verbose;
182181
PathScope pathScope;
183182
Predicate<PathType> pathTypeFilter;
@@ -246,7 +245,7 @@ public DependencyResolverRequestBuilder root(@Nonnull DependencyCoordinates root
246245
*/
247246
@Nonnull
248247
public DependencyResolverRequestBuilder dependencies(@Nullable List<DependencyCoordinates> dependencies) {
249-
this.dependencies = (dependencies != null) ? dependencies : Collections.emptyList();
248+
this.dependencies = (dependencies != null) ? dependencies : List.of();
250249
return this;
251250
}
252251

@@ -278,7 +277,7 @@ public DependencyResolverRequestBuilder dependency(@Nullable DependencyCoordinat
278277
@Nonnull
279278
public DependencyResolverRequestBuilder managedDependencies(
280279
@Nullable List<DependencyCoordinates> managedDependencies) {
281-
this.managedDependencies = (managedDependencies != null) ? managedDependencies : Collections.emptyList();
280+
this.managedDependencies = (managedDependencies != null) ? managedDependencies : List.of();
282281
return this;
283282
}
284283

api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.io.Serializable;
2222
import java.util.Collection;
23-
import java.util.Collections;
2423
import java.util.LinkedHashMap;
2524
import java.util.Map;
2625

@@ -44,7 +43,7 @@ public InputLocation(InputSource source) {
4443
this.lineNumber = -1;
4544
this.columnNumber = -1;
4645
this.source = source;
47-
this.locations = Collections.singletonMap(0, this);
46+
this.locations = Map.of(0, this);
4847
this.importedFrom = null;
4948
}
5049

@@ -60,8 +59,7 @@ public InputLocation(int lineNumber, int columnNumber, InputSource source, Objec
6059
this.lineNumber = lineNumber;
6160
this.columnNumber = columnNumber;
6261
this.source = source;
63-
this.locations =
64-
selfLocationKey != null ? Collections.singletonMap(selfLocationKey, this) : Collections.emptyMap();
62+
this.locations = selfLocationKey != null ? Map.of(selfLocationKey, this) : Map.of();
6563
this.importedFrom = null;
6664
}
6765

api/maven-api-spi/src/main/java/org/apache/maven/api/spi/LanguageProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* <pre>
3636
* public class CustomLanguageProvider implements LanguageProvider {
3737
* public Collection&lt;Language&gt; provides() {
38-
* return Collections.singleton(language("kotlin"));
38+
* return Set.of(language("kotlin"));
3939
* }
4040
* }
4141
* </pre>

api/maven-api-spi/src/main/java/org/apache/maven/api/spi/LifecycleProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* <pre>
3838
* public class CustomLifecycleProvider implements LifecycleProvider {
3939
* public Collection&lt;Lifecycle&gt; provides() {
40-
* return Collections.singleton(
40+
* return Set.of(
4141
* lifecycle("deploy-docker", Arrays.asList(
4242
* "build-image",
4343
* "tag-image",

api/maven-api-spi/src/main/java/org/apache/maven/api/spi/PathScopeProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* <pre>
3838
* public class CustomPathScopeProvider implements PathScopeProvider {
3939
* public Collection&lt;PathScope&gt; provides() {
40-
* return Collections.singleton(pathScope("integration-test",
40+
* return Set.of(pathScope("integration-test",
4141
* ProjectScope.TEST, DependencyScope.TEST));
4242
* }
4343
* }

api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ProjectScopeProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* <pre>
3636
* public class CustomProjectScopeProvider implements ProjectScopeProvider {
3737
* public Collection&lt;ProjectScope&gt; provides() {
38-
* return Collections.singleton(projectScope("integration-test"));
38+
* return Set.of(projectScope("integration-test"));
3939
* }
4040
* }
4141
* </pre>

compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.repository.internal;
2020

2121
import java.util.ArrayList;
22-
import java.util.Collections;
2322
import java.util.HashMap;
2423
import java.util.LinkedHashMap;
2524
import java.util.List;
@@ -104,7 +103,7 @@ private Dependency convert(org.apache.maven.model.Dependency dependency, Artifac
104103

105104
Map<String, String> props = null;
106105
if (system) {
107-
props = Collections.singletonMap(MavenArtifactProperties.LOCAL_PATH, dependency.getSystemPath());
106+
props = Map.of(MavenArtifactProperties.LOCAL_PATH, dependency.getSystemPath());
108107
}
109108

110109
Artifact artifact = new DefaultArtifact(

0 commit comments

Comments
 (0)