Class PathElements

Object
com.owenfeehan.pathpatternfinder.commonpath.PathElements
All Implemented Interfaces:
Iterable<String>

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 Details

    • intersect

      public void intersect​(Path path)
      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

      public Path 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

      public Iterator<String> iterator()
      Iterates through each common element (including the root as the first element if it exists).
      Specified by:
      iterator in interface Iterable<String>