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/8a1c328e Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8a1c328e Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8a1c328e Branch: refs/heads/TINKERPOP-1642 Commit: 8a1c328e701aada723519e2db63f74d0034076e9 Parents: 149a6f8 Author: Stephen Mallette <[email protected]> Authored: Fri Mar 10 13:27:01 2017 -0500 Committer: Stephen Mallette <[email protected]> Committed: Mon Mar 20 14:09:02 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/8a1c328e/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;
