Class PathElements
Object
com.owenfeehan.pathpatternfinder.commonpath.PathElements
public class PathElements extends Object implements Iterable<String>
A list of elements of a path from the left to right.
This is a mutable class whose paths can be changed after calls to intersect(java.nio.file.Path)
.
- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description void
intersect(Path path)
Takes only a maximal subset (from the left) between existing elements and this new pathboolean
isEmpty()
Are there no elements?Iterator<String>
iterator()
Iterates through each common element (including the root as the first element if it exists).int
size()
Number of path-elements in the prefix.int
sizeIgnoreRoot()
Number of path-elements in the prefix that aren't a root.Path
toPath()
Converts the elements to a path.
-
Method Details
-
intersect
Takes only a maximal subset (from the left) between existing elements and this new path- Parameters:
path
- the path to intersect with the existing prefix.
-
toPath
Converts the elements to a path.If the path has no elements, then the current working directory is returned as
.
- Returns:
- a newly created path, including a root if it exists, and the common elements.
-
size
public int size()Number of path-elements in the prefix.- Returns:
- the number of elements
-
sizeIgnoreRoot
public int sizeIgnoreRoot()Number of path-elements in the prefix that aren't a root.- Returns:
- the number of elements
-
isEmpty
public boolean isEmpty()Are there no elements?- Returns:
- true if there are zero elements, false otherwise.
-
iterator
Iterates through each common element (including the root as the first element if it exists).
-