blob: 3e59c596b29e3daeaa9e3acd1c94526c647bb79f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package org.glavo.javah;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import static org.glavo.javah.Utils.*;
public class ClassPath implements SearchPath {
private final Path path;
private final List<Path> roots;
public ClassPath(Path path) {
Objects.requireNonNull(path);
this.path = path.toAbsolutePath();
Path root = classPathRoot(path);
roots = root == null ? Collections.emptyList() : SearchPath.multiReleaseRoots(root);
}
@Override
public Path search(ClassName name) {
Objects.requireNonNull(name);
return SearchPath.searchFromRoots(roots, name);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ClassPath classPath = (ClassPath) o;
return Objects.equals(path, classPath.path);
}
@Override
public int hashCode() {
return path.hashCode();
}
@Override
public String toString() {
return "ClassPath[" + path + "]";
}
}
|