1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.services;
20
21 import java.util.Collection;
22
23 import org.apache.maven.api.ArtifactCoordinates;
24 import org.apache.maven.api.Session;
25 import org.apache.maven.api.annotations.Experimental;
26 import org.apache.maven.api.annotations.Immutable;
27 import org.apache.maven.api.annotations.Nonnull;
28 import org.apache.maven.api.annotations.NotThreadSafe;
29
30 import static org.apache.maven.api.services.BaseRequest.nonNull;
31
32
33
34
35
36
37 @Experimental
38 @Immutable
39 public interface ArtifactResolverRequest {
40 @Nonnull
41 Session getSession();
42
43 @Nonnull
44 Collection<? extends ArtifactCoordinates> getCoordinates();
45
46 @Nonnull
47 static ArtifactResolverRequestBuilder builder() {
48 return new ArtifactResolverRequestBuilder();
49 }
50
51 @Nonnull
52 static ArtifactResolverRequest build(
53 @Nonnull Session session, @Nonnull Collection<? extends ArtifactCoordinates> coordinates) {
54 return builder()
55 .session(nonNull(session, "session cannot be null"))
56 .coordinates(nonNull(coordinates, "coordinates cannot be null"))
57 .build();
58 }
59
60 @NotThreadSafe
61 class ArtifactResolverRequestBuilder {
62 Session session;
63 Collection<? extends ArtifactCoordinates> coordinates;
64
65 ArtifactResolverRequestBuilder() {}
66
67 @Nonnull
68 public ArtifactResolverRequestBuilder session(Session session) {
69 this.session = session;
70 return this;
71 }
72
73 @Nonnull
74 public ArtifactResolverRequestBuilder coordinates(Collection<? extends ArtifactCoordinates> coordinates) {
75 this.coordinates = coordinates;
76 return this;
77 }
78
79 @Nonnull
80 public ArtifactResolverRequest build() {
81 return new DefaultArtifactResolverRequest(session, coordinates);
82 }
83
84 private static class DefaultArtifactResolverRequest extends BaseRequest implements ArtifactResolverRequest {
85 @Nonnull
86 private final Collection<? extends ArtifactCoordinates> coordinates;
87
88 DefaultArtifactResolverRequest(
89 @Nonnull Session session, @Nonnull Collection<? extends ArtifactCoordinates> coordinates) {
90 super(session);
91 this.coordinates = unmodifiable(nonNull(coordinates, "coordinates cannot be null"));
92 }
93
94 @Nonnull
95 @Override
96 public Collection<? extends ArtifactCoordinates> getCoordinates() {
97 return coordinates;
98 }
99 }
100 }
101 }