public class ForwardRelativePath extends Object implements Comparable<ForwardRelativePath>
Modifier and Type | Field and Description |
---|---|
static ForwardRelativePath |
EMPTY |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ForwardRelativePath that) |
boolean |
endsWith(ForwardRelativePath path)
This path ends with given path.
|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty() |
Optional<ForwardRelativePath> |
nameAsPath()
Last segment of path
|
static ForwardRelativePath |
of(String path)
Parse a string into path.
|
static ForwardRelativePath |
ofPath(Path path)
Construct from given relative
Path . |
static ForwardRelativePath |
ofSubstring(String path,
int offset)
Parse a string into path removing .
|
Optional<ForwardRelativePath> |
parent()
Path without last segment
|
String |
relativize(ForwardRelativePath other)
Constructs a relative path between this path and a given path.
|
ForwardRelativePath |
resolve(ForwardRelativePath other)
Append given path to the current path
|
ForwardRelativePath |
resolve(String other) |
com.google.common.collect.ImmutableList<String> |
segments() |
boolean |
startsWith(ForwardRelativePath path)
This path starts with given path.
|
Path |
toPath(FileSystem fileSystem)
Convert file path to a relative path in given filesystem.
|
Path |
toPathDefaultFileSystem()
Convert this path to the
Path of FileSystems.getDefault() . |
String |
toPathPrefix()
A string to be prepended to another path to make a relative path
|
RelPath |
toRelPath(FileSystem fileSystem) |
String |
toString() |
public static final ForwardRelativePath EMPTY
public static ForwardRelativePath of(String path)
This function throws if path is not normalized (e. g. contains two consecutive slashes).
public static ForwardRelativePath ofSubstring(String path, int offset)
This function throws if path is not normalized (e. g. contains two consecutive slashes).
offset
- is the number of characters to be removed from the path before parsing (useful in
certain cases to avoid extra string allocation).public static ForwardRelativePath ofPath(Path path)
Path
.
This functions calls Path.normalize()
. Throw if path is not relative.
public ForwardRelativePath resolve(ForwardRelativePath other)
public ForwardRelativePath resolve(String other)
public boolean isEmpty()
public Path toPath(FileSystem fileSystem)
Note this function is optimized for BuckFileSystem
(avoids re-parsing and
re-interning).
public Path toPathDefaultFileSystem()
Path
of FileSystems.getDefault()
.public RelPath toRelPath(FileSystem fileSystem)
public Optional<ForwardRelativePath> nameAsPath()
public Optional<ForwardRelativePath> parent()
public String toPathPrefix()
public boolean startsWith(ForwardRelativePath path)
ab/cd
starts with ab/cd
, ab
, but not ab/c
.
public boolean endsWith(ForwardRelativePath path)
ab/cd
ends with ab/cd
, cd
, but not b/cd
.
public com.google.common.collect.ImmutableList<String> segments()
public String relativize(ForwardRelativePath other)
Returns empty string when paths are equal.
public int compareTo(ForwardRelativePath that)
compareTo
in interface Comparable<ForwardRelativePath>