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