All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sbt.jni.javah.search.ClassPath Maven / Gradle / Ivy

package com.github.sbt.jni.javah.search;

import com.github.sbt.jni.javah.ClassName;

import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static com.github.sbt.jni.javah.util.Utils.*;

public class ClassPath implements SearchPath {
    private final Path path;
    private final List 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 + "]";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy