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