aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/glavo/javah/ClassPath.java
blob: 552cb9e21de3dd98494303a015dcdbaa5214886e (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
package org.glavo.javah;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;

public class ClassPath implements SearchPath {
    private final Path path;
    private final List<Path> searchPaths;

    public ClassPath(Path path) {
        Objects.requireNonNull(path);
        this.path = path;
        searchPaths = Utils.getPathsFrom(path);
    }

    @Override
    public Path searchClass(String className) {
        Objects.requireNonNull(className);
        return Utils.searchFrom(searchPaths, className);
    }

    @Override
    public String toString() {
        return "ClassPath[" + path + "]";
    }
}