Skip to content

Commit

Permalink
feat(#5): remove redundant methods
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 22, 2023
1 parent e29cf41 commit e12ae61
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/main/java/com/yegor256/Jhome.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

/**
* Finds {@code JAVA_HOME} even if the environment variable is not set.
Expand Down Expand Up @@ -54,23 +55,16 @@ public Jhome() {
this.home = Jhome.base();
}

/**
* Get the {@code JAVA_HOME}.
* @return The path of it
*/
public Path path() {
return this.home;
}

/**
* Find the file inside {@code JAVA_HOME}.
* @param loc Location, e.g. {@code "bin/java"}
* @return The path of it
*/
public Path path(final String loc) {
return this.home.resolve(
loc.replace("/", File.separator).replace("\\", File.separator)
);
public Path path(final String... loc) {
return Arrays.stream(loc)
.map(subpath -> subpath.replace("/", File.separator).replace("\\", File.separator))
.map(Paths::get)
.reduce(this.home, Path::resolve);
}

/**
Expand Down

0 comments on commit e12ae61

Please sign in to comment.