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.Session;
22 import org.apache.maven.api.annotations.Experimental;
23 import org.apache.maven.api.annotations.Immutable;
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
34 @Experimental
35 @Immutable
36 public interface ArtifactFactoryRequest {
37
38 @Nonnull
39 Session getSession();
40
41 String getGroupId();
42
43 String getArtifactId();
44
45 String getVersion();
46
47 String getClassifier();
48
49 String getExtension();
50
51 String getType();
52
53 static ArtifactFactoryRequest build(
54 Session session, String groupId, String artifactId, String version, String extension) {
55 return ArtifactFactoryRequest.builder()
56 .session(nonNull(session, "session cannot be null"))
57 .groupId(groupId)
58 .artifactId(artifactId)
59 .version(version)
60 .extension(extension)
61 .build();
62 }
63
64 static ArtifactFactoryRequest build(
65 Session session,
66 String groupId,
67 String artifactId,
68 String version,
69 String classifier,
70 String extension,
71 String type) {
72 return ArtifactFactoryRequest.builder()
73 .session(nonNull(session, "session cannot be null"))
74 .groupId(groupId)
75 .artifactId(artifactId)
76 .version(version)
77 .classifier(classifier)
78 .extension(extension)
79 .type(type)
80 .build();
81 }
82
83 static ArtifactFactoryRequestBuilder builder() {
84 return new ArtifactFactoryRequestBuilder();
85 }
86
87 @NotThreadSafe
88 class ArtifactFactoryRequestBuilder {
89 private Session session;
90 private String groupId;
91 private String artifactId;
92 private String version;
93 private String classifier;
94 private String extension;
95 private String type;
96
97 ArtifactFactoryRequestBuilder() {}
98
99 public ArtifactFactoryRequestBuilder session(Session session) {
100 this.session = session;
101 return this;
102 }
103
104 public ArtifactFactoryRequestBuilder groupId(String groupId) {
105 this.groupId = groupId;
106 return this;
107 }
108
109 public ArtifactFactoryRequestBuilder artifactId(String artifactId) {
110 this.artifactId = artifactId;
111 return this;
112 }
113
114 public ArtifactFactoryRequestBuilder version(String version) {
115 this.version = version;
116 return this;
117 }
118
119 public ArtifactFactoryRequestBuilder classifier(String classifier) {
120 this.classifier = classifier;
121 return this;
122 }
123
124 public ArtifactFactoryRequestBuilder extension(String extension) {
125 this.extension = extension;
126 return this;
127 }
128
129 public ArtifactFactoryRequestBuilder type(String type) {
130 this.type = type;
131 return this;
132 }
133
134 public ArtifactFactoryRequest build() {
135 return new DefaultArtifactFactoryRequest(
136 session, groupId, artifactId, version, classifier, extension, type);
137 }
138
139 private static class DefaultArtifactFactoryRequest extends BaseRequest<Session>
140 implements ArtifactFactoryRequest {
141 private final String groupId;
142 private final String artifactId;
143 private final String version;
144 private final String classifier;
145 private final String extension;
146 private final String type;
147
148 DefaultArtifactFactoryRequest(
149 @Nonnull Session session,
150 String groupId,
151 String artifactId,
152 String version,
153 String classifier,
154 String extension,
155 String type) {
156 super(session);
157 this.groupId = groupId;
158 this.artifactId = artifactId;
159 this.version = version;
160 this.classifier = classifier;
161 this.extension = extension;
162 this.type = type;
163 }
164
165 @Override
166 public String getGroupId() {
167 return groupId;
168 }
169
170 @Override
171 public String getArtifactId() {
172 return artifactId;
173 }
174
175 @Override
176 public String getVersion() {
177 return version;
178 }
179
180 @Override
181 public String getClassifier() {
182 return classifier;
183 }
184
185 @Override
186 public String getExtension() {
187 return extension;
188 }
189
190 @Override
191 public String getType() {
192 return type;
193 }
194 }
195 }
196 }