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 org.apache.maven.api.ArtifactCoordinates;
22 import org.apache.maven.api.Session;
23 import org.apache.maven.api.annotations.Experimental;
24 import org.apache.maven.api.annotations.Nonnull;
25 import org.apache.maven.api.annotations.NotThreadSafe;
26
27 import static org.apache.maven.api.services.BaseRequest.nonNull;
28
29
30
31
32
33 @Experimental
34 public interface VersionResolverRequest {
35
36 @Nonnull
37 Session getSession();
38
39 @Nonnull
40 ArtifactCoordinates getArtifactCoordinates();
41
42 @Nonnull
43 static VersionResolverRequest build(@Nonnull Session session, @Nonnull ArtifactCoordinates artifactCoordinates) {
44 return builder()
45 .session(nonNull(session, "session cannot be null"))
46 .artifactCoordinates(nonNull(artifactCoordinates, "artifactCoordinates cannot be null"))
47 .build();
48 }
49
50 @Nonnull
51 static VersionResolverRequestBuilder builder() {
52 return new VersionResolverRequestBuilder();
53 }
54
55 @NotThreadSafe
56 class VersionResolverRequestBuilder {
57 Session session;
58 ArtifactCoordinates artifactCoordinates;
59
60 public VersionResolverRequestBuilder session(Session session) {
61 this.session = session;
62 return this;
63 }
64
65 public VersionResolverRequestBuilder artifactCoordinates(ArtifactCoordinates artifactCoordinates) {
66 this.artifactCoordinates = artifactCoordinates;
67 return this;
68 }
69
70 public VersionResolverRequest build() {
71 return new DefaultVersionResolverRequest(session, artifactCoordinates);
72 }
73
74 private static class DefaultVersionResolverRequest extends BaseRequest implements VersionResolverRequest {
75 private final ArtifactCoordinates artifactCoordinates;
76
77 @SuppressWarnings("checkstyle:ParameterNumber")
78 DefaultVersionResolverRequest(@Nonnull Session session, @Nonnull ArtifactCoordinates artifactCoordinates) {
79 super(session);
80 this.artifactCoordinates = artifactCoordinates;
81 }
82
83 @Nonnull
84 @Override
85 public ArtifactCoordinates getArtifactCoordinates() {
86 return artifactCoordinates;
87 }
88 }
89 }
90 }