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.net.URI;
23 import java.nio.file.Path;
24
25 import org.apache.maven.building.FileSource;
26 import org.apache.maven.model.locator.ModelLocator;
27
28
29
30
31
32 public class FileModelSource extends FileSource implements ModelSource3 {
33
34
35
36
37
38
39
40 @Deprecated
41 public FileModelSource(File pomFile) {
42 super(pomFile);
43 }
44
45
46
47
48
49
50
51 public FileModelSource(Path pomPath) {
52 super(pomPath);
53 }
54
55
56
57
58
59
60
61 @Deprecated
62 public File getPomFile() {
63 return getFile();
64 }
65
66 @Override
67 public ModelSource3 getRelatedSource(ModelLocator locator, String relPath) {
68 relPath = relPath.replace('\\', File.separatorChar).replace('/', File.separatorChar);
69
70 Path path = getPath().getParent().resolve(relPath);
71
72 Path relatedPom = locator.locateExistingPom(path);
73
74 if (relatedPom != null) {
75 return new FileModelSource(relatedPom.normalize());
76 }
77
78 return null;
79 }
80
81 @Override
82 public URI getLocationURI() {
83 return getPath().toUri();
84 }
85
86 @Override
87 public boolean equals(Object obj) {
88 if (this == obj) {
89 return true;
90 }
91
92 if (obj == null) {
93 return false;
94 }
95
96 if (!FileModelSource.class.equals(obj.getClass())) {
97 return false;
98 }
99 FileModelSource other = (FileModelSource) obj;
100 return getPath().equals(other.getPath());
101 }
102
103 @Override
104 public int hashCode() {
105 return getPath().hashCode();
106 }
107 }