View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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   * @since 4.0
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 implements ArtifactFactoryRequest {
140             private final String groupId;
141             private final String artifactId;
142             private final String version;
143             private final String classifier;
144             private final String extension;
145             private final String type;
146 
147             DefaultArtifactFactoryRequest(
148                     @Nonnull Session session,
149                     String groupId,
150                     String artifactId,
151                     String version,
152                     String classifier,
153                     String extension,
154                     String type) {
155                 super(session);
156                 this.groupId = groupId;
157                 this.artifactId = artifactId;
158                 this.version = version;
159                 this.classifier = classifier;
160                 this.extension = extension;
161                 this.type = type;
162             }
163 
164             @Override
165             public String getGroupId() {
166                 return groupId;
167             }
168 
169             @Override
170             public String getArtifactId() {
171                 return artifactId;
172             }
173 
174             @Override
175             public String getVersion() {
176                 return version;
177             }
178 
179             @Override
180             public String getClassifier() {
181                 return classifier;
182             }
183 
184             @Override
185             public String getExtension() {
186                 return extension;
187             }
188 
189             @Override
190             public String getType() {
191                 return type;
192             }
193         }
194     }
195 }