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.ArtifactCoordinates;
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 DefaultArtifactCoordinates implements ArtifactCoordinates {
33 private final @Nonnull InternalSession session;
34 private final @Nonnull org.eclipse.aether.artifact.Artifact coordinates;
35
36 public DefaultArtifactCoordinates(
37 @Nonnull InternalSession session, @Nonnull org.eclipse.aether.artifact.Artifact coordinates) {
38 this.session = nonNull(session, "session");
39 this.coordinates = nonNull(coordinates, "coordinates");
40 }
41
42 public org.eclipse.aether.artifact.Artifact getCoordinates() {
43 return coordinates;
44 }
45
46 @Nonnull
47 @Override
48 public String getGroupId() {
49 return coordinates.getGroupId();
50 }
51
52 @Nonnull
53 @Override
54 public String getArtifactId() {
55 return coordinates.getArtifactId();
56 }
57
58 @Nonnull
59 @Override
60 public VersionConstraint getVersionConstraint() {
61 return session.parseVersionConstraint(coordinates.getVersion());
62 }
63
64 @Override
65 public String getExtension() {
66 return coordinates.getExtension();
67 }
68
69 @Nonnull
70 @Override
71 public String getClassifier() {
72 return coordinates.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 DefaultArtifactCoordinates that = (DefaultArtifactCoordinates) o;
84 return Objects.equals(this.getGroupId(), that.getGroupId())
85 && Objects.equals(this.getArtifactId(), that.getArtifactId())
86 && Objects.equals(this.getVersionConstraint(), that.getVersionConstraint())
87 && Objects.equals(this.getClassifier(), that.getClassifier());
88 }
89
90 @Override
91 public int hashCode() {
92 return Objects.hash(getGroupId(), getArtifactId(), getVersionConstraint(), getClassifier());
93 }
94
95 @Override
96 public String toString() {
97 return coordinates.toString();
98 }
99 }