Class TraversalHelper
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper
 
- 
 public final class TraversalHelper extends Object Utility class that provides functions that manipulateTraversalisntances. These functions are helpful when writingTraversalStrategyimplementations.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Traversal.Admin<?,?>>
 TaddHasContainer(T traversal, HasContainer hasContainer)Used to left-fold aHasContainerto aHasContainerHolderif it exists.static <S> voidaddToCollection(Collection<S> collection, S s, long bulk)Adds the supplied element to the collection according to the provided bulk count.static booleananyStepRecursively(Predicate<Step> predicate, TraversalParent step)Determine if any child step of aTraversalParentmatch the step given the providedPredicate.static booleananyStepRecursively(Predicate<Step> predicate, Traversal.Admin<?,?> traversal)static voidapplyTraversalRecursively(Consumer<Traversal.Admin<?,?>> consumer, Traversal.Admin<?,?> traversal)static voidapplyTraversalRecursively(Consumer<Traversal.Admin<?,?>> consumer, Traversal.Admin<?,?> traversal, boolean applyToChildrenOnly)static voidcopyLabels(Step<?,?> fromStep, Step<?,?> toStep, boolean moveLabels)Copies labels from one step to another.static Set<Step<?,?>>gatherGValuePlaceholders(Traversal.Admin<?,?> traversal)Gathers all steps that implementGValueHolderand returns them as a set.static Map<Step,Collection<GValue<?>>>gatherStepGValues(Traversal.Admin<?,?> traversal)Gathers all steps that implementGValueHolderand returns a map from step to the collection ofGValueinstances they hold.static <S> Optional<S>getFirstStepOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal)Returns the first step in the traversal that is assignable to the supplied class, if present.static Set<String>getLabels(Traversal.Admin<?,?> traversal)Collects all labels (including hidden) present in the traversal and its child traversals.static <S> Optional<S>getLastStepOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal)Returns the last step in the traversal that is assignable to the supplied class, if present.static <T extends Traversal.Admin<?,?>>
 Set<PopContaining.PopInstruction>getPopInstructions(T traversal)Used to get PopInstruction of a traversal.static Traversal.Admin<?,?>getRootTraversal(Traversal.Admin<?,?> traversal)Returns the root traversal by walking up the parent chain until encountering anEmptyStepparent.static StringgetShortName(Step step, int maxLength)Returns the name of step truncated to maxLength.static <S> List<S>getStepsOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal)Returns all steps in the given traversal that are instances of (i.e., assignable to) the supplied class.static <S> List<S>getStepsOfAssignableClassRecursively(Class<S> stepClass, Traversal.Admin<?,?> traversal)Recursively collects steps assignable to the supplied class from the traversal and all its child traversals (both local and global).static <S> List<S>getStepsOfAssignableClassRecursively(Scope scope, Class<S> stepClass, Traversal.Admin<?,?> traversal)Recursively collects steps assignable to the supplied class from the traversal and its child traversals scoped by the given Scope.static List<Step<?,?>>getStepsOfAssignableClassRecursively(Traversal.Admin<?,?> traversal, Class<?>... stepClasses)Recursively collects steps that are assignable to any of the supplied classes from the traversal and all its child traversals (both local and global).static List<Step<?,?>>getStepsOfAssignableClassRecursivelyFromDepth(Traversal.Admin<?,?> traversal, Class<?>... stepClasses)Recursively collects steps assignable to any of the supplied classes from the traversal and children, then orders the result by depth (deepest child steps first).static <S> List<S>getStepsOfClass(Class<S> stepClass, Traversal.Admin<?,?> traversal)Returns all steps in the given traversal whose concrete class equals the supplied class.static Set<Scoping.Variable>getVariableLocations(Traversal.Admin<?,?> traversal)Determines whether labels are referenced at the START and/or END of the traversal by inspecting the first and last steps (and appropriate children for certain step types).static booleanhasAllStepsOfClass(Traversal.Admin<?,?> traversal, Class<?>... classesToCheck)Tests whether every step in the traversal is an instance of at least one of the supplied classes.static booleanhasLabels(Traversal.Admin<?,?> traversal)Determines whether any non-hidden labels are present anywhere in the traversal or its children.static booleanhasOnlyStepsOfAssignableClassesRecursively(Collection<Class> stepClasses, Traversal.Admin<?,?> traversal)Checks if the traversal only has steps that are equal to or assignable from the given step classes.static booleanhasStepOfAssignableClass(Class superClass, Traversal.Admin<?,?> traversal)Determine if the traversal has a step of an assignable class.static booleanhasStepOfAssignableClassRecursively(Class stepClass, Traversal.Admin<?,?> traversal)Determine if the traversal has a step of an assignable class in the currentTraversaland its local and global child traversals.static booleanhasStepOfAssignableClassRecursively(Collection<Class> stepClasses, Traversal.Admin<?,?> traversal)Determine if the traversal has any of the supplied steps of an assignable class in the currentTraversaland its global or local child traversals.static booleanhasStepOfAssignableClassRecursively(Scope scope, Class stepClass, Traversal.Admin<?,?> traversal)static booleanhasStepOfAssignableClassRecursively(Scope scope, Collection<Class> stepClasses, Traversal.Admin<?,?> traversal)static booleanhasStepOfClass(Class stepClass, Traversal.Admin<?,?> traversal)Determine if the traversal has a step of a particular class.static booleanhasStepOfClass(Traversal.Admin<?,?> traversal, Class<?>... classesToCheck)Tests whether any step in the traversal is an instance of any of the supplied classes.static <S,E>
 voidinsertAfterStep(Step<S,E> insertStep, Step<?,S> beforeStep, Traversal.Admin<?,?> traversal)Insert a step after a specified step instance.static <S,E>
 voidinsertBeforeStep(Step<S,E> insertStep, Step<E,?> afterStep, Traversal.Admin<?,?> traversal)Insert a step before a specified step instance.static <S,E>
 Step<?,E>insertTraversal(int insertIndex, Traversal.Admin<S,E> insertTraversal, Traversal.Admin<?,?> traversal)Inserts all steps from the supplied insertTraversal into the specified traversal starting at the given index.static <S,E>
 Step<?,E>insertTraversal(Step<?,S> previousStep, Traversal.Admin<S,E> insertTraversal, Traversal.Admin<?,?> traversal)Inserts all steps from the supplied insertTraversal directly after the given previousStep in the specified traversal, preserving their order.static booleanisGlobalChild(Traversal.Admin<?,?> traversal)Determines whether the supplied traversal is a global child of its parent (as opposed to a local child).static booleanisLocalProperties(Traversal.Admin<?,?> traversal)Determines whether the given traversal only touches local vertex/edge properties (i.e.static booleanisLocalStarGraph(Traversal.Admin<?,?> traversal)Determines whether a traversal is confined to a single-star neighborhood of a starting vertex (i.e., a topologically local traversal over a vertex and its incident edges/adjacent vertices) without expanding further into the graph or pulling arbitrary properties that would require remote access.static <S,E>
 voidmoveStep(Step<S,E> stepToMove, int indexToMoveTo, Traversal.Admin<?,?> traversal)Moves a step to a new position.static booleanonGraphComputer(Traversal.Admin<?,?> traversal)Determines if the traversal is executing on aGraphComputerby walking up the parent chain and checking for aTraversalVertexProgramStep.static voidreIdSteps(StepPosition stepPosition, Traversal.Admin<?,?> traversal)Reassigns identifiers for every step in the supplied traversal using the provided StepPosition state object.static voidremoveAllSteps(Traversal.Admin<?,?> traversal)Removes all steps from the traversal.static Traversal.Admin<?,?>removeStep(Step<?,?> stepToRemove, Traversal.Admin<?,?> traversal)Removes the specified step from the traversal and returns the traversal for chaining.static <S,E>
 voidremoveToTraversal(Step<S,?> startStep, Step<?,E> endStep, Traversal.Admin<S,E> newTraversal)Removes steps from the traversal starting at startStep up to but not including endStep and appends them to newTraversal, preserving order.static <S,E>
 voidreplaceStep(Step<S,E> removeStep, Step<S,E> insertStep, Traversal.Admin<?,?> traversal)Replace a step with a new step.static <S,E>
 intstepIndex(Step<S,E> step, Traversal.Admin<?,?> traversal)Gets the index of a particular step in theTraversal.
 
- 
- 
- 
Method Detail- 
isLocalPropertiespublic static boolean isLocalProperties(Traversal.Admin<?,?> traversal) Determines whether the given traversal only touches local vertex/edge properties (i.e. does not traverse the graph topology). This returns false if a step is encountered that walks the graph (e.g. VertexStep/EdgeVertexStep) or if a repeat's global children contain such steps. TraversalParent children are inspected recursively.
 - 
isLocalStarGraphpublic static boolean isLocalStarGraph(Traversal.Admin<?,?> traversal) Determines whether a traversal is confined to a single-star neighborhood of a starting vertex (i.e., a topologically local traversal over a vertex and its incident edges/adjacent vertices) without expanding further into the graph or pulling arbitrary properties that would require remote access. This method delegates to a state-machine helper and returns true if the traversal remains within the local star graph.
 - 
insertBeforeSteppublic static <S,E> void insertBeforeStep(Step<S,E> insertStep, Step<E,?> afterStep, Traversal.Admin<?,?> traversal) Insert a step before a specified step instance.- Parameters:
- insertStep- the step to insert
- afterStep- the step to insert the new step before
- traversal- the traversal on which the action should occur
 
 - 
insertAfterSteppublic static <S,E> void insertAfterStep(Step<S,E> insertStep, Step<?,S> beforeStep, Traversal.Admin<?,?> traversal) Insert a step after a specified step instance.- Parameters:
- insertStep- the step to insert
- beforeStep- the step to insert the new step after
- traversal- the traversal on which the action should occur
 
 - 
replaceSteppublic static <S,E> void replaceStep(Step<S,E> removeStep, Step<S,E> insertStep, Traversal.Admin<?,?> traversal) Replace a step with a new step. When a step is replaced, it is also removed from theGValueManager.- Parameters:
- removeStep- the step to remove
- insertStep- the step to insert
- traversal- the traversal on which the action will occur
 
 - 
moveSteppublic static <S,E> void moveStep(Step<S,E> stepToMove, int indexToMoveTo, Traversal.Admin<?,?> traversal) Moves a step to a new position.- Parameters:
- stepToMove- the step to move
- indexToMoveTo- the index in the traversal to move it to
- traversal- the traversal to move the step in which must be the same as the one assigned to the step
 
 - 
insertTraversalpublic static <S,E> Step<?,E> insertTraversal(Step<?,S> previousStep, Traversal.Admin<S,E> insertTraversal, Traversal.Admin<?,?> traversal) Inserts all steps from the supplied insertTraversal directly after the given previousStep in the specified traversal, preserving their order.- Parameters:
- previousStep- the step after which to insert the traversal
- insertTraversal- the traversal whose steps will be inserted
- traversal- the traversal to receive the steps
- Returns:
- the last step that was inserted
 
 - 
insertTraversalpublic static <S,E> Step<?,E> insertTraversal(int insertIndex, Traversal.Admin<S,E> insertTraversal, Traversal.Admin<?,?> traversal) Inserts all steps from the supplied insertTraversal into the specified traversal starting at the given index. Steps are inserted in order.- Parameters:
- insertIndex- the position at which to start inserting
- insertTraversal- the traversal whose steps will be inserted
- traversal- the traversal to receive the steps
- Returns:
- the last step that was inserted (or the existing step at insertIndex if no steps exist)
 
 - 
removeToTraversalpublic static <S,E> void removeToTraversal(Step<S,?> startStep, Step<?,E> endStep, Traversal.Admin<S,E> newTraversal) Removes steps from the traversal starting at startStep up to but not including endStep and appends them to newTraversal, preserving order.- Parameters:
- startStep- the first step to move
- endStep- the terminal step at which to stop (not moved)
- newTraversal- the traversal to receive the moved steps
 
 - 
stepIndexpublic static <S,E> int stepIndex(Step<S,E> step, Traversal.Admin<?,?> traversal) Gets the index of a particular step in theTraversal.- Parameters:
- step- the step to retrieve the index for
- traversal- the traversal to perform the action on
- Returns:
- the index of the step or -1 if the step is not present
 
 - 
getStepsOfClasspublic static <S> List<S> getStepsOfClass(Class<S> stepClass, Traversal.Admin<?,?> traversal) Returns all steps in the given traversal whose concrete class equals the supplied class. If the supplied class is an interface registered as a step contract, the method will match by exact equality to any of the registered concrete implementations for that contract. For example, calling this method withGraphStepContractwill not match on the interface but instead will match on itsGraphStepContract.CONCRETE_STEPS.- Parameters:
- stepClass- the concrete step type to match, or a registered contract interface
- traversal- the traversal to scan
- Returns:
- a list of matching steps (preserving traversal order)
 
 - 
getStepsOfAssignableClasspublic static <S> List<S> getStepsOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal) Returns all steps in the given traversal that are instances of (i.e., assignable to) the supplied class.- Parameters:
- stepClass- the class or interface to test with- Class.isAssignableFrom(Class)
- traversal- the traversal to scan
- Returns:
- a list of matching steps (preserving traversal order)
 
 - 
getLastStepOfAssignableClasspublic static <S> Optional<S> getLastStepOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal) Returns the last step in the traversal that is assignable to the supplied class, if present.- Parameters:
- stepClass- the class or interface to test with- Class.isAssignableFrom(Class)
- traversal- the traversal to scan
- Returns:
- the last matching step or Optional.empty()if none found
 
 - 
getFirstStepOfAssignableClasspublic static <S> Optional<S> getFirstStepOfAssignableClass(Class<S> stepClass, Traversal.Admin<?,?> traversal) Returns the first step in the traversal that is assignable to the supplied class, if present.- Parameters:
- stepClass- the class or interface to test with- Class.isAssignableFrom(Class)
- traversal- the traversal to scan
- Returns:
- the first matching step or Optional.empty()if none found
 
 - 
getStepsOfAssignableClassRecursivelypublic static <S> List<S> getStepsOfAssignableClassRecursively(Class<S> stepClass, Traversal.Admin<?,?> traversal) Recursively collects steps assignable to the supplied class from the traversal and all its child traversals (both local and global).- Parameters:
- stepClass- the class or interface to test with- Class.isAssignableFrom(Class)
- traversal- the root traversal to scan
- Returns:
- a list of matching steps found anywhere in the traversal tree
 
 - 
getStepsOfAssignableClassRecursivelypublic static <S> List<S> getStepsOfAssignableClassRecursively(Scope scope, Class<S> stepClass, Traversal.Admin<?,?> traversal) Recursively collects steps assignable to the supplied class from the traversal and its child traversals scoped by the given Scope.- Parameters:
- scope- whether to include local, global, or both child traversals (null for both)
- stepClass- the class or interface to test with- Class.isAssignableFrom(Class)
- traversal- the root traversal to scan
- Returns:
- a list of matching steps found anywhere within the scoped traversal tree
 
 - 
getStepsOfAssignableClassRecursivelypublic static List<Step<?,?>> getStepsOfAssignableClassRecursively(Traversal.Admin<?,?> traversal, Class<?>... stepClasses) Recursively collects steps that are assignable to any of the supplied classes from the traversal and all its child traversals (both local and global).- Parameters:
- traversal- the root traversal to scan
- stepClasses- the classes or interfaces to test with- Class.isAssignableFrom(Class)
- Returns:
- a list of matching steps found anywhere in the traversal tree
 
 - 
getStepsOfAssignableClassRecursivelyFromDepthpublic static List<Step<?,?>> getStepsOfAssignableClassRecursivelyFromDepth(Traversal.Admin<?,?> traversal, Class<?>... stepClasses) Recursively collects steps assignable to any of the supplied classes from the traversal and children, then orders the result by depth (deepest child steps first). Depth ordering is determined byDepthComparator.- Parameters:
- traversal- the root traversal to scan
- stepClasses- the classes or interfaces to test with- Class.isAssignableFrom(Class)
- Returns:
- a list of matching steps ordered from deepest to shallowest
 
 - 
isGlobalChildpublic static boolean isGlobalChild(Traversal.Admin<?,?> traversal) Determines whether the supplied traversal is a global child of its parent (as opposed to a local child). Walks up the parent chain until the root to make this determination.- Parameters:
- traversal- the traversal to test
- Returns:
- true if the traversal is a global child; false if it is a local child
 
 - 
hasStepOfClasspublic static boolean hasStepOfClass(Class stepClass, Traversal.Admin<?,?> traversal) Determine if the traversal has a step of a particular class.- Parameters:
- stepClass- the step class to look for
- traversal- the traversal to perform the action on
- Returns:
- trueif the class is found and- falseotherwise
 
 - 
hasStepOfAssignableClasspublic static boolean hasStepOfAssignableClass(Class superClass, Traversal.Admin<?,?> traversal) Determine if the traversal has a step of an assignable class.- Parameters:
- superClass- the step super class to look for
- traversal- the traversal to perform the action on
- Returns:
- trueif the class is found and- falseotherwise
 
 - 
hasStepOfAssignableClassRecursivelypublic static boolean hasStepOfAssignableClassRecursively(Class stepClass, Traversal.Admin<?,?> traversal) Determine if the traversal has a step of an assignable class in the currentTraversaland its local and global child traversals.- Parameters:
- stepClass- the step class to look for
- traversal- the traversal in which to look for the given step class
- Returns:
- trueif any step in the given traversal (and its child traversals) is an instance of the given- stepClass, otherwise- false.
 
 - 
hasStepOfAssignableClassRecursivelypublic static boolean hasStepOfAssignableClassRecursively(Scope scope, Class stepClass, Traversal.Admin<?,?> traversal) Determine if the traversal has a step of an assignable class in the currentTraversaland itsScopechild traversals.- Parameters:
- scope- the child traversal scope to check
- stepClass- the step class to look for
- traversal- the traversal in which to look for the given step class
- Returns:
- trueif any step in the given traversal (and its child traversals) is an instance of the given- stepClass, otherwise- false.
 
 - 
hasStepOfAssignableClassRecursivelypublic static boolean hasStepOfAssignableClassRecursively(Collection<Class> stepClasses, Traversal.Admin<?,?> traversal) Determine if the traversal has any of the supplied steps of an assignable class in the currentTraversaland its global or local child traversals.- Parameters:
- stepClasses- the step classes to look for
- traversal- the traversal in which to look for the given step classes
- Returns:
- trueif any step in the given traversal (and its child traversals) is an instance of a class provided in- stepClasses, otherwise- false.
 
 - 
hasStepOfAssignableClassRecursivelypublic static boolean hasStepOfAssignableClassRecursively(Scope scope, Collection<Class> stepClasses, Traversal.Admin<?,?> traversal) Determine if the traversal has any of the supplied steps of an assignable class in the currentTraversaland itsScopechild traversals.- Parameters:
- scope- whether to check global or local children (null for both).
- stepClasses- the step classes to look for
- traversal- the traversal in which to look for the given step classes
- Returns:
- trueif any step in the given traversal (and its child traversals) is an instance of a class provided in- stepClasses, otherwise- false.
 
 - 
hasOnlyStepsOfAssignableClassesRecursivelypublic static boolean hasOnlyStepsOfAssignableClassesRecursively(Collection<Class> stepClasses, Traversal.Admin<?,?> traversal) Checks if the traversal only has steps that are equal to or assignable from the given step classes.- Parameters:
- stepClasses- the collection of allowed step classes
- traversal- the traversal to check
- Returns:
- true if all steps in the traversal are equal to or assignable from the given classes
 
 - 
anyStepRecursivelypublic static boolean anyStepRecursively(Predicate<Step> predicate, Traversal.Admin<?,?> traversal) - Parameters:
- predicate- the match function
- traversal- the traversal to perform the action on
- Returns:
- trueif there is a match and- falseotherwise
 
 - 
anyStepRecursivelypublic static boolean anyStepRecursively(Predicate<Step> predicate, TraversalParent step) Determine if any child step of aTraversalParentmatch the step given the providedPredicate.- Parameters:
- predicate- the match function
- step- the step to perform the action on
- Returns:
- trueif there is a match and- falseotherwise
 
 - 
applyTraversalRecursivelypublic static void applyTraversalRecursively(Consumer<Traversal.Admin<?,?>> consumer, Traversal.Admin<?,?> traversal) - Parameters:
- consumer- the function to apply to the each traversal in the tree
- traversal- the root traversal to start application
 
 - 
applyTraversalRecursivelypublic static void applyTraversalRecursively(Consumer<Traversal.Admin<?,?>> consumer, Traversal.Admin<?,?> traversal, boolean applyToChildrenOnly) - Parameters:
- consumer- the function to apply
- traversal- the root traversal
- applyToChildrenOnly- if true, only child traversals receive the function (the root is skipped)
 
 - 
addToCollectionpublic static <S> void addToCollection(Collection<S> collection, S s, long bulk) Adds the supplied element to the collection according to the provided bulk count. If the collection is aBulkSet, the element is added with the given bulk. If it is a Set, the element is added once. Otherwise the element is added repeatedly bulk times.- Parameters:
- collection- the collection to mutate
- s- the element to add
- bulk- the bulk count
 
 - 
getShortNamepublic static String getShortName(Step step, int maxLength) Returns the name of step truncated to maxLength. An ellipses is appended when the name exceeds maxLength.- Parameters:
- step-
- maxLength- Includes the 3 "..." characters that will be appended when the length of the name exceeds maxLength.
- Returns:
- short step name.
 
 - 
reIdStepspublic static void reIdSteps(StepPosition stepPosition, Traversal.Admin<?,?> traversal) Reassigns identifiers for every step in the supplied traversal using the provided StepPosition state object. The StepPosition is mutated to reflect the current parent context (x/y/z/parentId) and each step receives a new id via StepPosition#nextXId().- Parameters:
- stepPosition- the position tracker to mutate and use to generate ids
- traversal- the traversal whose steps will be re-identified
 
 - 
getRootTraversalpublic static Traversal.Admin<?,?> getRootTraversal(Traversal.Admin<?,?> traversal) Returns the root traversal by walking up the parent chain until encountering anEmptyStepparent.- Parameters:
- traversal- a traversal that may be nested
- Returns:
- the root (top-most) traversal
 
 - 
hasLabelspublic static boolean hasLabels(Traversal.Admin<?,?> traversal) Determines whether any non-hidden labels are present anywhere in the traversal or its children.- Parameters:
- traversal- the traversal to inspect
- Returns:
- true if at least one non-hidden label exists; false otherwise
 
 - 
getLabelspublic static Set<String> getLabels(Traversal.Admin<?,?> traversal) Collects all labels (including hidden) present in the traversal and its child traversals.- Parameters:
- traversal- the traversal to inspect
- Returns:
- a set of labels
 
 - 
getVariableLocationspublic static Set<Scoping.Variable> getVariableLocations(Traversal.Admin<?,?> traversal) Determines whether labels are referenced at the START and/or END of the traversal by inspecting the first and last steps (and appropriate children for certain step types). Returned variables include START and/or END.- Parameters:
- traversal- the traversal to inspect
- Returns:
- a set containing zero, one, or both of Scoping.Variable.STARTandScoping.Variable.END
 
 - 
onGraphComputerpublic static boolean onGraphComputer(Traversal.Admin<?,?> traversal) Determines if the traversal is executing on aGraphComputerby walking up the parent chain and checking for aTraversalVertexProgramStep.- Parameters:
- traversal- the traversal to inspect
- Returns:
- true if the traversal is under a TraversalVertexProgramStep; false otherwise
 
 - 
removeSteppublic static Traversal.Admin<?,?> removeStep(Step<?,?> stepToRemove, Traversal.Admin<?,?> traversal) Removes the specified step from the traversal and returns the traversal for chaining.- Parameters:
- stepToRemove- the step to remove
- traversal- the traversal to mutate
- Returns:
- the traversal argument for chaining
 
 - 
removeAllStepspublic static void removeAllSteps(Traversal.Admin<?,?> traversal) Removes all steps from the traversal.- Parameters:
- traversal- the traversal to clear
 
 - 
copyLabelspublic static void copyLabels(Step<?,?> fromStep, Step<?,?> toStep, boolean moveLabels) Copies labels from one step to another. If moveLabels is true, labels are removed from the source after copying; otherwise labels are left in place and only added to the target.- Parameters:
- fromStep- the step to copy labels from
- toStep- the step to add labels to
- moveLabels- whether to remove labels from the source after copying
 
 - 
hasAllStepsOfClasspublic static boolean hasAllStepsOfClass(Traversal.Admin<?,?> traversal, Class<?>... classesToCheck) Tests whether every step in the traversal is an instance of at least one of the supplied classes.- Parameters:
- traversal- the traversal to test
- classesToCheck- the classes to check with- Class.isInstance(Object)
- Returns:
- true if all steps match at least one class; false otherwise
 
 - 
hasStepOfClasspublic static boolean hasStepOfClass(Traversal.Admin<?,?> traversal, Class<?>... classesToCheck) Tests whether any step in the traversal is an instance of any of the supplied classes.- Parameters:
- traversal- the traversal to test
- classesToCheck- the classes to check with- Class.isInstance(Object)
- Returns:
- true if any step matches at least one class; false otherwise
 
 - 
addHasContainerpublic static <T extends Traversal.Admin<?,?>> T addHasContainer(T traversal, HasContainer hasContainer) - Parameters:
- traversal- the traversal to fold or append.
- hasContainer- the container to add left or append.
- Returns:
- the has container folded or appended traversal
 
 - 
gatherStepGValuespublic static Map<Step,Collection<GValue<?>>> gatherStepGValues(Traversal.Admin<?,?> traversal) Gathers all steps that implementGValueHolderand returns a map from step to the collection ofGValueinstances they hold.- Parameters:
- traversal- the traversal to scan recursively
- Returns:
- a map of steps to their GValue collections
 
 - 
gatherGValuePlaceholderspublic static Set<Step<?,?>> gatherGValuePlaceholders(Traversal.Admin<?,?> traversal) Gathers all steps that implementGValueHolderand returns them as a set. This is useful when only the presence of placeholders is needed and not the values themselves.- Parameters:
- traversal- the traversal to scan recursively
- Returns:
- the set of steps that are GValueHolders
 
 - 
getPopInstructionspublic static <T extends Traversal.Admin<?,?>> Set<PopContaining.PopInstruction> getPopInstructions(T traversal) Used to get PopInstruction of a traversal. Pop Instruction includes the labels it needs, and the pop type for each label.- Type Parameters:
- T- the traversal type
- Parameters:
- traversal- the traversal to get Scope Context for
- Returns:
- A Set of PopContaining.PopInstructionvalues which contain the label and Pop value
 
 
- 
 
-