View Javadoc
1   package org.apache.maven.api.services;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
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  
26  import org.apache.maven.api.Session;
27  import org.apache.maven.api.annotations.NotThreadSafe;
28  
29  import static org.apache.maven.api.services.BaseRequest.nonNull;
30  
31  /**
32   *
33   *
34   * @since 4.0
35   */
36  @Experimental
37  @Immutable
38  public interface ArtifactFactoryRequest
39  {
40  
41      @Nonnull
42      Session getSession();
43  
44      String getGroupId();
45  
46      String getArtifactId();
47  
48      String getVersion();
49  
50      String getClassifier();
51  
52      String getExtension();
53  
54      String getType();
55  
56      static ArtifactFactoryRequest build( Session session, String groupId, String artifactId,
57                                           String version, String extension )
58      {
59          return ArtifactFactoryRequest.builder()
60                  .session( nonNull( session, "session cannot be null" ) )
61                  .groupId( groupId )
62                  .artifactId( artifactId )
63                  .version( version )
64                  .extension( extension )
65                  .build();
66      }
67  
68      static ArtifactFactoryRequest build( Session session, String groupId, String artifactId,
69                                           String version, String classifier, String extension, String type )
70      {
71          return ArtifactFactoryRequest.builder()
72                  .session( nonNull( session, "session cannot be null" ) )
73                  .groupId( groupId )
74                  .artifactId( artifactId )
75                  .version( version )
76                  .classifier( classifier )
77                  .extension( extension )
78                  .type( type )
79                  .build();
80      }
81  
82      static ArtifactFactoryRequestBuilder builder()
83      {
84          return new ArtifactFactoryRequestBuilder();
85      }
86  
87      @NotThreadSafe
88      class ArtifactFactoryRequestBuilder
89      {
90          private Session session;
91          private String groupId;
92          private String artifactId;
93          private String version;
94          private String classifier;
95          private String extension;
96          private String type;
97  
98          ArtifactFactoryRequestBuilder()
99          {
100         }
101 
102         public ArtifactFactoryRequestBuilder session( Session session )
103         {
104             this.session = session;
105             return this;
106         }
107 
108         public ArtifactFactoryRequestBuilder groupId( String groupId )
109         {
110             this.groupId = groupId;
111             return this;
112         }
113 
114         public ArtifactFactoryRequestBuilder artifactId( String artifactId )
115         {
116             this.artifactId = artifactId;
117             return this;
118         }
119 
120         public ArtifactFactoryRequestBuilder version( String version )
121         {
122             this.version = version;
123             return this;
124         }
125 
126         public ArtifactFactoryRequestBuilder classifier( String classifier )
127         {
128             this.classifier = classifier;
129             return this;
130         }
131 
132         public ArtifactFactoryRequestBuilder extension( String extension )
133         {
134             this.extension = extension;
135             return this;
136         }
137 
138         public ArtifactFactoryRequestBuilder type( String type )
139         {
140             this.type = type;
141             return this;
142         }
143 
144         public ArtifactFactoryRequest build()
145         {
146             return new DefaultArtifactFactoryRequest( session, groupId, artifactId, version,
147                                                       classifier, extension, type );
148         }
149 
150         private static class DefaultArtifactFactoryRequest extends BaseRequest implements ArtifactFactoryRequest
151         {
152             private final String groupId;
153             private final String artifactId;
154             private final String version;
155             private final String classifier;
156             private final String extension;
157             private final String type;
158 
159             DefaultArtifactFactoryRequest( @Nonnull Session session,
160                                            String groupId,
161                                            String artifactId,
162                                            String version,
163                                            String classifier,
164                                            String extension,
165                                            String type )
166             {
167                 super( session );
168                 this.groupId = groupId;
169                 this.artifactId = artifactId;
170                 this.version = version;
171                 this.classifier = classifier;
172                 this.extension = extension;
173                 this.type = type;
174             }
175 
176             @Override
177             public String getGroupId()
178             {
179                 return groupId;
180             }
181 
182             @Override
183             public String getArtifactId()
184             {
185                 return artifactId;
186             }
187 
188             @Override
189             public String getVersion()
190             {
191                 return version;
192             }
193 
194             @Override
195             public String getClassifier()
196             {
197                 return classifier;
198             }
199 
200             @Override
201             public String getExtension()
202             {
203                 return extension;
204             }
205 
206             @Override
207             public String getType()
208             {
209                 return type;
210             }
211         }
212     }
213 
214 }