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