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.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   * @since 4.0.0
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  }