1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.building;
20
21 import java.io.File;
22 import java.nio.file.Path;
23 import java.util.Objects;
24
25 import org.apache.maven.building.FileSource;
26
27
28
29
30
31
32 public class ArtifactModelSource extends FileSource implements ModelSource {
33 private final String groupId;
34
35 private final String artifactId;
36
37 private final String version;
38
39 private final int hashCode;
40
41 @Deprecated
42 public ArtifactModelSource(File file, String groupId, String artifactId, String version) {
43 super(file);
44 this.groupId = groupId;
45 this.artifactId = artifactId;
46 this.version = version;
47 this.hashCode = Objects.hash(groupId, artifactId, version);
48 }
49
50 public ArtifactModelSource(Path path, String groupId, String artifactId, String version) {
51 super(path);
52 this.groupId = groupId;
53 this.artifactId = artifactId;
54 this.version = version;
55 this.hashCode = Objects.hash(groupId, artifactId, version);
56 }
57
58 public String getGroupId() {
59 return groupId;
60 }
61
62 public String getArtifactId() {
63 return artifactId;
64 }
65
66 public String getVersion() {
67 return version;
68 }
69
70 @Override
71 public int hashCode() {
72 return hashCode;
73 }
74
75 @Override
76 public boolean equals(Object obj) {
77 if (this == obj) {
78 return true;
79 }
80 if (obj == null) {
81 return false;
82 }
83
84 if (!ArtifactModelSource.class.equals(obj.getClass())) {
85 return false;
86 }
87
88 ArtifactModelSource other = (ArtifactModelSource) obj;
89 return Objects.equals(artifactId, other.artifactId)
90 && Objects.equals(groupId, other.groupId)
91 && Objects.equals(version, other.version);
92 }
93
94 @Override
95 public String toString() {
96 return groupId + ":" + artifactId + ":" + version;
97 }
98 }