org.apache.tinkerpop.gremlin.process.traversal

## Interface Path

- All Superinterfaces:
    Cloneable, Iterable<Object>

      public interface Path
      extends Cloneable, Iterable<Object>

  A Path denotes a particular walk through a `Graph` as defined by a `Traversal`. In abstraction, any Path implementation maintains two lists: a list of sets of labels and a list of objects. The list of labels are the labels of the steps traversed. The list of objects are the objects traversed.
  Author:
    Marko A. Rodriguez (http://markorodriguez.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `Path.Exceptions`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Path` | `clone()`
    `Path` | `extend(Object object, Set<String> labels)` Add a new step to the path with an object and any number of associated labels.
    `Path` | `extend(Set<String> labels)` Add labels to the head of the path.
    `default void` | `forEach(BiConsumer<Object,Set<String>> consumer)`
    `default <A> A` | `get(int index)` Get the object associated with the specified index into the path.
    `default <A> A` | `get(Pop pop, String label)` Pop the object(s) associated with the label of the path.
    `default <A> A` | `get(String label)` Get the object associated with the particular label of the path.
    `default boolean` | `hasLabel(String label)` Return true if the path has the specified label, else return false.
    `default <A> A` | `head()` Get the head of the path.
    `default boolean` | `isEmpty()` Determine if the path is empty or not.
    `default boolean` | `isSimple()` Determines whether the path is a simple or not.
    `default Iterator<Object>` | `iterator()`
    `List<Set<String>>` | `labels()` An ordered list of the labels associated with the path The set of labels for a particular step are ordered by the order in which `extend(Object, Set)` was called.
    `List<Object>` | `objects()` An ordered list of the objects in the path.
    `default boolean` | `popEquals(Pop pop, Object other)`
    `Path` | `retract(Set<String> labels)` Remove labels from path.
    `default int` | `size()` Get the number of step in the path.
    `default Stream<org.javatuples.Pair<Object,Set<String>>>` | `stream()`
    `default Path` | `subPath(String fromLabel, String toLabel)` Isolate a sub-path from the path object.

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Method Detail

    - #### size

          default int size()

      Get the number of step in the path.
      Returns:
        the size of the path

    - #### isEmpty

          default boolean isEmpty()

      Determine if the path is empty or not.
      Returns:
        whether the path is empty or not.

    - #### head

          default <A> A head()

      Get the head of the path.
      Type Parameters:
        `A` - the type of the head of the path
      Returns:
        the head of the path

    - #### extend

          Path extend(Object object,
                      Set<String> labels)

      Add a new step to the path with an object and any number of associated labels.
      Parameters:
        `object` - the new head of the path
        `labels` - the labels at the head of the path
      Returns:
        the extended path

    - #### extend

          Path extend(Set<String> labels)

      Add labels to the head of the path.
      Parameters:
        `labels` - the labels at the head of the path
      Returns:
        the path with added labels

    - #### retract

          Path retract(Set<String> labels)

      Remove labels from path.
      Parameters:
        `labels` - the labels to remove
      Returns:
        the path with removed labels

    - #### get

          default <A> A get(String label)
                     throws IllegalArgumentException

      Get the object associated with the particular label of the path. If the path as multiple labels of the type, then return a `List` of those objects.
      Type Parameters:
        `A` - the type of the object associated with the label
      Parameters:
        `label` - the label of the path
      Returns:
        the object associated with the label of the path
      Throws:
        `IllegalArgumentException` - if the path does not contain the label

    - #### get

          default <A> A get(Pop pop,
                            String label)
                     throws IllegalArgumentException

      Pop the object(s) associated with the label of the path.
      Type Parameters:
        `A` - the type of the object associated with the label
      Parameters:
        `pop` - first for least recent, last for most recent, and all for all in a list
        `label` - the label of the path
      Returns:
        the object associated with the label of the path
      Throws:
        `IllegalArgumentException` - if the path does not contain the label

    - #### get

          default <A> A get(int index)

      Get the object associated with the specified index into the path.
      Type Parameters:
        `A` - the type of the object associated with the index
      Parameters:
        `index` - the index of the path
      Returns:
        the object associated with the index of the path

    - #### hasLabel

          default boolean hasLabel(String label)

      Return true if the path has the specified label, else return false.
      Parameters:
        `label` - the label to search for
      Returns:
        true if the label exists in the path

    - #### objects

          List<Object> objects()

      An ordered list of the objects in the path.
      Returns:
        the objects of the path

    - #### labels

          List<Set<String>> labels()

      An ordered list of the labels associated with the path The set of labels for a particular step are ordered by the order in which `extend(Object, Set)` was called.
      Returns:
        the labels of the path

    - #### clone

          Path clone()

    - #### isSimple

          default boolean isSimple()

      Determines whether the path is a simple or not. A simple path has no cycles and thus, no repeated objects.
      Returns:
        Whether the path is simple or not

    - #### iterator

          default Iterator<Object> iterator()

      Specified by:
        `iterator` in interface `Iterable<Object>`

    - #### forEach

          default void forEach(BiConsumer<Object,Set<String>> consumer)

    - #### stream

          default Stream<org.javatuples.Pair<Object,Set<String>>> stream()

    - #### popEquals

          default boolean popEquals(Pop pop,
                                    Object other)

    - #### subPath

          default Path subPath(String fromLabel,
                               String toLabel)

      Isolate a sub-path from the path object. The isolation is based solely on the path labels. The to-label is inclusive. Thus, from "b" to "c" would isolate the example path as follows `a,[b,c],d`. Note that if there are multiple path segments with the same label, then its the last occurrence that is isolated. For instance, from "b" to "c" would be `a,b,[b,c,d,c]`.
      Parameters:
        `fromLabel` - The label to start recording the sub-path from.
        `toLabel` - The label to end recording the sub-path to.
      Returns:
        the isolated sub-path.

Copyright © 2013–2019 Apache Software Foundation. All rights reserved.