Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8484] Replace BaseRequest#unmodifiable with List.copyOf() #2037

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.api.services;

import java.util.Collection;
import java.util.List;

import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.RemoteRepository;
Expand Down Expand Up @@ -115,7 +116,7 @@ private static class DefaultArtifactDeployerRequest extends BaseRequest<Session>
int retryFailedDeploymentCount) {
super(session);
this.repository = requireNonNull(repository, "repository cannot be null");
this.artifacts = unmodifiable(requireNonNull(artifacts, "artifacts cannot be null"));
this.artifacts = List.copyOf(requireNonNull(artifacts, "artifacts cannot be null"));
this.retryFailedDeploymentCount = retryFailedDeploymentCount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Session;
Expand Down Expand Up @@ -89,7 +90,7 @@ static class DefaultArtifactInstallerRequest extends BaseRequest<Session> implem

DefaultArtifactInstallerRequest(@Nonnull Session session, @Nonnull Collection<ProducedArtifact> artifacts) {
super(session);
this.artifacts = unmodifiable(requireNonNull(artifacts, "artifacts cannot be null"));
this.artifacts = List.copyOf(requireNonNull(artifacts, "artifacts cannot be null"));
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static class DefaultArtifactResolverRequest extends BaseRequest<Session>
@Nonnull Collection<? extends ArtifactCoordinates> coordinates,
@Nonnull List<RemoteRepository> repositories) {
super(session);
this.coordinates = unmodifiable(requireNonNull(coordinates, "coordinates cannot be null"));
this.coordinates = List.copyOf(requireNonNull(coordinates, "coordinates cannot be null"));
this.repositories = repositories;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
*/
package org.apache.maven.api.services;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import org.apache.maven.api.ProtoSession;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
Expand All @@ -46,10 +42,4 @@ protected BaseRequest(@Nonnull S session) {
public S getSession() {
return session;
}

protected static <T> Collection<T> unmodifiable(Collection<T> obj) {
return obj != null && !obj.isEmpty()
? Collections.unmodifiableCollection(new ArrayList<>(obj))
: Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ static class DefaultDependencyResolverRequest extends BaseRequest<Session>
this.project = project;
this.rootArtifact = rootArtifact;
this.root = root;
this.dependencies = unmodifiable(requireNonNull(dependencies, "dependencies cannot be null"));
this.dependencies = List.copyOf(requireNonNull(dependencies, "dependencies cannot be null"));
this.managedDependencies =
unmodifiable(requireNonNull(managedDependencies, "managedDependencies cannot be null"));
List.copyOf(requireNonNull(managedDependencies, "managedDependencies cannot be null"));
this.verbose = verbose;
this.pathScope = requireNonNull(pathScope, "pathScope cannot be null");
this.pathTypeFilter = (pathTypeFilter != null) ? pathTypeFilter : (t) -> true;
Expand Down
Loading