1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl;
20
21 import java.util.Objects;
22
23 import org.apache.maven.api.ArtifactCoordinate;
24 import org.apache.maven.api.VersionConstraint;
25 import org.apache.maven.api.annotations.Nonnull;
26
27 import static org.apache.maven.internal.impl.Utils.nonNull;
28
29
30
31
32 public class DefaultArtifactCoordinate implements ArtifactCoordinate {
33 private final @Nonnull InternalSession session;
34 private final @Nonnull org.eclipse.aether.artifact.Artifact coordinate;
35
36 public DefaultArtifactCoordinate(
37 @Nonnull InternalSession session, @Nonnull org.eclipse.aether.artifact.Artifact coordinate) {
38 this.session = nonNull(session, "session");
39 this.coordinate = nonNull(coordinate, "coordinate");
40 }
41
42 public org.eclipse.aether.artifact.Artifact getCoordinate() {
43 return coordinate;
44 }
45
46 @Nonnull
47 @Override
48 public String getGroupId() {
49 return coordinate.getGroupId();
50 }
51
52 @Nonnull
53 @Override
54 public String getArtifactId() {
55 return coordinate.getArtifactId();
56 }
57
58 @Nonnull
59 @Override
60 public VersionConstraint getVersion() {
61 return session.parseVersionConstraint(coordinate.getVersion());
62 }
63
64 @Override
65 public String getExtension() {
66 return coordinate.getExtension();
67 }
68
69 @Nonnull
70 @Override
71 public String getClassifier() {
72 return coordinate.getClassifier();
73 }
74
75 @Override
76 public boolean equals(Object o) {
77 if (this == o) {
78 return true;
79 }
80 if (o == null || getClass() != o.getClass()) {
81 return false;
82 }
83 DefaultArtifactCoordinate that = (DefaultArtifactCoordinate) o;
84 return Objects.equals(this.getGroupId(), that.getGroupId())
85 && Objects.equals(this.getArtifactId(), that.getArtifactId())
86 && Objects.equals(this.getVersion(), that.getVersion())
87 && Objects.equals(this.getClassifier(), that.getClassifier());
88 }
89
90 @Override
91 public int hashCode() {
92 return Objects.hash(getGroupId(), getArtifactId(), getVersion(), getClassifier());
93 }
94
95 @Override
96 public String toString() {
97 return coordinate.toString();
98 }
99 }