View Javadoc
1   package org.apache.maven.api;
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  /**
27   * The {@code Coordinate} object is used to point to an {@link Artifact}
28   * but the version may be specified as a range instead of an exact version.
29   *
30   * @since 4.0
31   */
32  @Experimental
33  @Immutable
34  public interface ArtifactCoordinate
35  {
36  
37      /**
38       * The groupId of the artifact.
39       *
40       * @return The groupId.
41       */
42      @Nonnull
43      String getGroupId();
44  
45      /**
46       * The artifactId of the artifact.
47       *
48       * @return The artifactId.
49       */
50      @Nonnull
51      String getArtifactId();
52  
53      /**
54       * The classifier of the artifact.
55       *
56       * @return The classifier or an empty string if none, never {@code null}.
57       */
58      @Nonnull
59      String getClassifier();
60  
61      /**
62       * The version of the artifact.
63       *
64       * @return The version.
65       */
66      @Nonnull
67      VersionRange getVersion();
68  
69      /**
70       * The extension of the artifact.
71       *
72       * @return The extension or an empty string if none, never {@code null}.
73       */
74      @Nonnull
75      String getExtension();
76  
77      /**
78       * Unique id identifying this artifact
79       */
80      default String getId()
81      {
82          return getGroupId()
83                  + ":" + getArtifactId()
84                  + ":" + getExtension()
85                  + ( getClassifier().isEmpty() ? "" : ":" + getClassifier() )
86                  + ":" + getVersion();
87      }
88  
89  }