TINKERPOP-1642 Minor refactoring to get rid of duplicate code
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/88a3f60c Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/88a3f60c Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/88a3f60c Branch: refs/heads/master Commit: 88a3f60ce66ce4ff55de8ecefabfc4b22f277f62 Parents: f693cb7 Author: Stephen Mallette <sp...@genoprime.com> Authored: Fri Mar 10 13:27:01 2017 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Wed Mar 29 11:20:44 2017 -0400 ---------------------------------------------------------------------- .../process/traversal/util/TraversalHelper.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/88a3f60c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java index 5163824..95862d0 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java @@ -417,7 +417,7 @@ public final class TraversalHelper { * Determine if any step in {@link Traversal} or its children match the step given the provided {@link Predicate}. * * @param predicate the match function - * @param traversal th traversal to perform the action on + * @param traversal the traversal to perform the action on * @return {@code true} if there is a match and {@code false} otherwise */ public static boolean anyStepRecursively(final Predicate<Step> predicate, final Traversal.Admin<?, ?> traversal) { @@ -425,18 +425,19 @@ public final class TraversalHelper { if (predicate.test(step)) { return true; } - if (step instanceof TraversalParent) { - for (final Traversal.Admin<?, ?> localChild : ((TraversalParent) step).getLocalChildren()) { - if (anyStepRecursively(predicate, localChild)) return true; - } - for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) { - if (anyStepRecursively(predicate, globalChild)) return true; - } - } + + if (step instanceof TraversalParent) anyStepRecursively(predicate, ((TraversalParent) step)); } return false; } + /** + * Determine if any child step of a {@link TraversalParent} match the step given the provided {@link Predicate}. + * + * @param predicate the match function + * @param step the step to perform the action on + * @return {@code true} if there is a match and {@code false} otherwise + */ public static boolean anyStepRecursively(final Predicate<Step> predicate, final TraversalParent step) { for (final Traversal.Admin<?, ?> localChild : step.getLocalChildren()) { if (anyStepRecursively(predicate, localChild)) return true;