Class PathParentIterator

  • All Implemented Interfaces:
    Iterator<String>

    public class PathParentIterator
    extends Object
    implements Iterator<String>
    Iterates over a ZooKeeper path. Each iteration goes up one parent path. Thus, the effect of the iterator is to iterate over the initial path and then all of its parents.
    • Method Detail

      • forAll

        public static PathParentIterator forAll​(String path)
        Return a new PathParentIterator that iterates from the given path to all parents.
        Parameters:
        path - initial path
      • forPathOnly

        public static PathParentIterator forPathOnly​(String path)
        Return a new PathParentIterator that only returns the given path - i.e. does not iterate to parent paths.
        Parameters:
        path - initial path
      • asIterable

        public Iterable<String> asIterable()
        Return an Iterable view so that this Iterator can be used in for each statements. IMPORTANT: the returned Iterable is single use only
        Returns:
        Iterable
      • atParentPath

        public boolean atParentPath()
        Returns true if this iterator is currently at a parent path as opposed to the initial path given to the constructor
        Returns:
        true/false