You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2019/11/04 11:27:23 UTC

[GitHub] [tinkerpop] jorgebay commented on a change in pull request #1211: TINKERPOP-1568 Changed Strategy Application Methodology

jorgebay commented on a change in pull request #1211: TINKERPOP-1568 Changed Strategy Application Methodology
URL: https://github.com/apache/tinkerpop/pull/1211#discussion_r341992514
 
 

 ##########
 File path: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
 ##########
 @@ -476,21 +478,30 @@ public default void reset() {
         public TraversalStrategies getStrategies();
 
         /**
-         * Set the {@link org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent} {@link Step} that is the parent of this traversal.
-         * Traversals can be nested and this is the means by which the traversal tree is connected.
+         * Set the {@link org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent} {@link Step} that is
+         * the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is
+         * connected.
          *
          * @param step the traversal holder parent step
          */
         public void setParent(final TraversalParent step);
 
         /**
-         * Get the {@link org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent} {@link Step} that is the parent of this traversal.
-         * Traversals can be nested and this is the means by which the traversal tree is walked.
+         * Get the {@link org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent} {@link Step} that is
+         * the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is
+         * walked.
          *
          * @return the traversal holder parent step
          */
         public TraversalParent getParent();
 
+        /**
+         * Determines if the traversal is at the root level.
+         */
+        public default boolean isRoot() {
+            return null == getParent() || getParent() instanceof EmptyStep;
 
 Review comment:
   `Traversal` implementors should use `EmptyStep` to signal "no parent" in `getParent()` method. All the `getParent()` callers expect `EmptyStep`. Can we document that return value of `getParent()` must not be null and avoid adding a null check here?
   
   Maybe we could do that in a separate ticket.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services