org.apache.tinkerpop.gremlin.process.traversal.util

## Class DefaultTraversal<S,E>

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal<S,E>

- All Implemented Interfaces:
    Serializable, AutoCloseable, Cloneable, Iterator<E>, Traversal<S,E>, Traversal.Admin<S,E>
  Direct Known Subclasses:
    DefaultGraphTraversal, ScriptTraversal

      public class DefaultTraversal<S,E>
      extends Object
      implements Traversal.Admin<S,E>

  Author:
    Marko A. Rodriguez (http://markorodriguez.com)
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal

      `Traversal.Admin<S,E>, Traversal.Exceptions, Traversal.Symbols`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Bytecode` | `bytecode`
    `protected TraverserGenerator` | `generator`
    `protected Graph` | `graph`
    `protected boolean` | `locked`
    `protected TraversalParent` | `parent`
    `protected Set<TraverserRequirement>` | `requirements`
    `protected TraversalSideEffects` | `sideEffects`
    `protected List<Step>` | `steps`
    `protected TraversalStrategies` | `strategies`
    `protected List<Step>` | `unmodifiableSteps`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultTraversal()`
    `DefaultTraversal(Bytecode bytecode)`
    `DefaultTraversal(Graph graph)`
    `DefaultTraversal(TraversalSource traversalSource)`
    `DefaultTraversal(TraversalSource traversalSource, Traversal.Admin<S,E> traversal)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addStart(Traverser.Admin<S> start)` Add a single `Traverser.Admin` object to the head of the traversal.
    `void` | `addStarts(Iterator<Traverser.Admin<S>> starts)` Add an iterator of `Traverser.Admin` objects to the head/start of the traversal.
    `<S2,E2> Traversal.Admin<S2,E2>` | `addStep(int index, Step<?,?> step)` Add a `Step` to an arbitrary point in the traversal.
    `void` | `applyStrategies()` Apply the registered `TraversalStrategies` to the traversal.
    `Traversal.Admin<S,E>` | `asAdmin()` Get access to administrative methods of the traversal via its accompanying `Traversal.Admin`.
    `DefaultTraversal<S,E>` | `clone()` Cloning is used to duplicate the traversal typically in OLAP environments.
    `boolean` | `equals(Object other)`
    `Bytecode` | `getBytecode()` Get the `Bytecode` associated with the construction of this traversal.
    `Step<?,E>` | `getEndStep()` Get the end/tail of the traversal.
    `Optional<Graph>` | `getGraph()`
    `TraversalParent` | `getParent()` Get the `TraversalParent` `Step` that is the parent of this traversal.
    `TraversalSideEffects` | `getSideEffects()` Get the `TraversalSideEffects` associated with the traversal.
    `Step<S,?>` | `getStartStep()` Get the start/head of the traversal.
    `List<Step>` | `getSteps()` Get the `Step` instances associated with this traversal.
    `TraversalStrategies` | `getStrategies()` Get the `TraversalStrategies` associated with this traversal.
    `TraverserGenerator` | `getTraverserGenerator()` Get the `TraverserGenerator` associated with this traversal.
    `Set<TraverserRequirement>` | `getTraverserRequirements()` Get the set of all `TraverserRequirement`s for this traversal.
    `int` | `hashCode()`
    `boolean` | `hasNext()`
    `boolean` | `isLocked()` When the traversal has had its `TraversalStrategies` applied to it, it is locked.
    `E` | `next()`
    `Traverser.Admin<E>` | `nextTraverser()`
    `<S2,E2> Traversal.Admin<S2,E2>` | `removeStep(int index)` Remove a `Step` from the traversal.
    `void` | `reset()` Call the `Step.reset()` method on every step in the traversal.
    `void` | `setGraph(Graph graph)`
    `void` | `setParent(TraversalParent step)` Set the `TraversalParent` `Step` that is the parent of this traversal.
    `void` | `setSideEffects(TraversalSideEffects sideEffects)` Set the `TraversalSideEffects` of this traversal.
    `void` | `setStrategies(TraversalStrategies strategies)` Set the `TraversalStrategies` to be used by this traversal at evaluation time.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin

      `addStep, equals, removeStep`

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal

      `close, explain, fill, forEachRemaining, forEachRemaining, iterate, next, profile, promise, toBulkSet, toList, toSet, toStream, tryNext`

    - ### Methods inherited from interface java.util.Iterator

      `remove`

- - ### Field Detail

    - #### graph

          protected transient Graph graph

    - #### steps

          protected List<Step> steps

    - #### unmodifiableSteps

          protected List<Step> unmodifiableSteps

    - #### parent

          protected TraversalParent parent

    - #### sideEffects

          protected TraversalSideEffects sideEffects

    - #### strategies

          protected TraversalStrategies strategies

    - #### generator

          protected transient TraverserGenerator generator

    - #### requirements

          protected Set<TraverserRequirement> requirements

    - #### locked

          protected boolean locked

    - #### bytecode

          protected Bytecode bytecode

  - ### Constructor Detail

    - #### DefaultTraversal

          public DefaultTraversal(Graph graph)

    - #### DefaultTraversal

          public DefaultTraversal(TraversalSource traversalSource)

    - #### DefaultTraversal

          public DefaultTraversal(TraversalSource traversalSource,
                                  Traversal.Admin<S,E> traversal)

    - #### DefaultTraversal

          public DefaultTraversal()

    - #### DefaultTraversal

          public DefaultTraversal(Bytecode bytecode)

  - ### Method Detail

    - #### getBytecode

          public Bytecode getBytecode()

      Description copied from interface: `Traversal.Admin`
      Get the `Bytecode` associated with the construction of this traversal.
      Specified by:
        `getBytecode` in interface `Traversal.Admin<S,E>`
      Returns:
        the byte code representation of the traversal

    - #### asAdmin

          public Traversal.Admin<S,E> asAdmin()

      Description copied from interface: `Traversal`
      Get access to administrative methods of the traversal via its accompanying `Traversal.Admin`.
      Specified by:
        `asAdmin` in interface `Traversal<S,E>`
      Returns:
        the admin of this traversal

    - #### getTraverserGenerator

          public TraverserGenerator getTraverserGenerator()

      Description copied from interface: `Traversal.Admin`
      Get the `TraverserGenerator` associated with this traversal. The traversal generator creates `Traverser` instances that are respective of the traversal's `TraverserRequirement`.
      Specified by:
        `getTraverserGenerator` in interface `Traversal.Admin<S,E>`
      Returns:
        the generator of traversers

    - #### applyStrategies

          public void applyStrategies()
                               throws IllegalStateException

      Description copied from interface: `Traversal.Admin`
      Apply the registered `TraversalStrategies` to the traversal. Once the strategies are applied, the traversal is "locked" and can no longer have steps added to it. The order of operations for strategy applications should be: globally id steps, apply strategies to root traversal, then to nested traversals.
      Specified by:
        `applyStrategies` in interface `Traversal.Admin<S,E>`
      Throws:
        `IllegalStateException` - if the `TraversalStrategies` have already been applied

    - #### getTraverserRequirements

          public Set<TraverserRequirement> getTraverserRequirements()

      Description copied from interface: `Traversal.Admin`
      Get the set of all `TraverserRequirement`s for this traversal.
      Specified by:
        `getTraverserRequirements` in interface `Traversal.Admin<S,E>`
      Returns:
        the features of a traverser that are required to execute properly in this traversal

    - #### getSteps

          public List<Step> getSteps()

      Description copied from interface: `Traversal.Admin`
      Get the `Step` instances associated with this traversal. The steps are ordered according to their linked list structure as defined by `Step.getPreviousStep()` and `Step.getNextStep()`.
      Specified by:
        `getSteps` in interface `Traversal.Admin<S,E>`
      Returns:
        the ordered steps of the traversal

    - #### nextTraverser

          public Traverser.Admin<E> nextTraverser()

      Specified by:
        `nextTraverser` in interface `Traversal.Admin<S,E>`

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in interface `Iterator<E>`

    - #### next

          public E next()

      Specified by:
        `next` in interface `Iterator<E>`

    - #### reset

          public void reset()

      Description copied from interface: `Traversal.Admin`
      Call the `Step.reset()` method on every step in the traversal.
      Specified by:
        `reset` in interface `Traversal.Admin<S,E>`

    - #### addStart

          public void addStart(Traverser.Admin<S> start)

      Description copied from interface: `Traversal.Admin`
      Add a single `Traverser.Admin` object to the head of the traversal. Users should typically not need to call this method. For dynamic inject of data, they should use `InjectStep`.
      Specified by:
        `addStart` in interface `Traversal.Admin<S,E>`
      Parameters:
        `start` - a traverser to add to the traversal

    - #### addStarts

          public void addStarts(Iterator<Traverser.Admin<S>> starts)

      Description copied from interface: `Traversal.Admin`
      Add an iterator of `Traverser.Admin` objects to the head/start of the traversal. Users should typically not need to call this method. For dynamic inject of data, they should use `InjectStep`.
      Specified by:
        `addStarts` in interface `Traversal.Admin<S,E>`
      Parameters:
        `starts` - an iterators of traversers

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getStartStep

          public Step<S,?> getStartStep()

      Description copied from interface: `Traversal.Admin`
      Get the start/head of the traversal. If the traversal is empty, then an `EmptyStep` instance is returned.
      Specified by:
        `getStartStep` in interface `Traversal.Admin<S,E>`
      Returns:
        the start step of the traversal

    - #### getEndStep

          public Step<?,E> getEndStep()

      Description copied from interface: `Traversal.Admin`
      Get the end/tail of the traversal. If the traversal is empty, then an `EmptyStep` instance is returned.
      Specified by:
        `getEndStep` in interface `Traversal.Admin<S,E>`
      Returns:
        the end step of the traversal

    - #### clone

          public DefaultTraversal<S,E> clone()

      Description copied from interface: `Traversal.Admin`
      Cloning is used to duplicate the traversal typically in OLAP environments.
      Specified by:
        `clone` in interface `Traversal.Admin<S,E>`
      Overrides:
        `clone` in class `Object`
      Returns:
        The cloned traversal

    - #### isLocked

          public boolean isLocked()

      Description copied from interface: `Traversal.Admin`
      When the traversal has had its `TraversalStrategies` applied to it, it is locked.
      Specified by:
        `isLocked` in interface `Traversal.Admin<S,E>`
      Returns:
        whether the traversal is locked

    - #### setSideEffects

          public void setSideEffects(TraversalSideEffects sideEffects)

      Description copied from interface: `Traversal.Admin`
      Set the `TraversalSideEffects` of this traversal.
      Specified by:
        `setSideEffects` in interface `Traversal.Admin<S,E>`
      Parameters:
        `sideEffects` - the sideEffects to set for this traversal.

    - #### getSideEffects

          public TraversalSideEffects getSideEffects()

      Description copied from interface: `Traversal.Admin`
      Get the `TraversalSideEffects` associated with the traversal.
      Specified by:
        `getSideEffects` in interface `Traversal.Admin<S,E>`
      Returns:
        The traversal sideEffects

    - #### setStrategies

          public void setStrategies(TraversalStrategies strategies)

      Description copied from interface: `Traversal.Admin`
      Set the `TraversalStrategies` to be used by this traversal at evaluation time.
      Specified by:
        `setStrategies` in interface `Traversal.Admin<S,E>`
      Parameters:
        `strategies` - the strategies to use on this traversal

    - #### getStrategies

          public TraversalStrategies getStrategies()

      Description copied from interface: `Traversal.Admin`
      Get the `TraversalStrategies` associated with this traversal.
      Specified by:
        `getStrategies` in interface `Traversal.Admin<S,E>`
      Returns:
        the strategies associated with this traversal

    - #### addStep

          public <S2,E2> Traversal.Admin<S2,E2> addStep(int index,
                                                        Step<?,?> step)
                                                 throws IllegalStateException

      Description copied from interface: `Traversal.Admin`
      Add a `Step` to an arbitrary point in the traversal.
      Specified by:
        `addStep` in interface `Traversal.Admin<S,E>`
      Type Parameters:
        `S2` - the new start type of the traversal (if the added step was a start step)
        `E2` - the new end type of the traversal (if the added step was an end step)
      Parameters:
        `index` - the location in the traversal to insert the step
        `step` - the step to add
      Returns:
        the newly modulated traversal
      Throws:
        `IllegalStateException` - if the `TraversalStrategies` have already been applied

    - #### removeStep

          public <S2,E2> Traversal.Admin<S2,E2> removeStep(int index)
                                                    throws IllegalStateException

      Description copied from interface: `Traversal.Admin`
      Remove a `Step` from the traversal.
      Specified by:
        `removeStep` in interface `Traversal.Admin<S,E>`
      Type Parameters:
        `S2` - the new start type of the traversal (if the removed step was a start step)
        `E2` - the new end type of the traversal (if the removed step was an end step)
      Parameters:
        `index` - the location in the traversal of the step to be evicted
      Returns:
        the newly modulated traversal
      Throws:
        `IllegalStateException` - if the `TraversalStrategies` have already been applied

    - #### setParent

          public void setParent(TraversalParent step)

      Description copied from interface: `Traversal.Admin`
      Set the `TraversalParent` `Step` that is the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is connected.
      Specified by:
        `setParent` in interface `Traversal.Admin<S,E>`
      Parameters:
        `step` - the traversal holder parent step

    - #### getParent

          public TraversalParent getParent()

      Description copied from interface: `Traversal.Admin`
      Get the `TraversalParent` `Step` that is the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is walked.
      Specified by:
        `getParent` in interface `Traversal.Admin<S,E>`
      Returns:
        the traversal holder parent step

    - #### getGraph

          public Optional<Graph> getGraph()

      Specified by:
        `getGraph` in interface `Traversal.Admin<S,E>`

    - #### setGraph

          public void setGraph(Graph graph)

      Specified by:
        `setGraph` in interface `Traversal.Admin<S,E>`

    - #### equals

          public boolean equals(Object other)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

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