This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2235
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 8ff4322aae05a6765c31a8f1a5c5ea86a6e601df
Author: stephen <[email protected]>
AuthorDate: Fri Nov 15 17:27:33 2019 -0500

    TINKERPOP-2235 Minor refactoring to get rid of duplicate code
---
 .../tinkerpop/gremlin/process/traversal/step/Scoping.java | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
index da7b0eb..fae7431 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -110,18 +111,8 @@ public interface Scoping {
     public enum Variable {START, END}
 
     public default <S> S getScopeValue(final Pop pop, final String key, final 
Traverser.Admin<?> traverser) throws IllegalArgumentException {
-        final Object object = traverser.get();
-        if (object instanceof Map && ((Map<String, S>) 
object).containsKey(key))
-            return ((Map<String, S>) object).get(key);
-        ///
-        if (traverser.getSideEffects().exists(key))
-            return traverser.getSideEffects().get(key);
-        ///
-        final Path path = traverser.path();
-        if (path.hasLabel(key))
-            return path.get(pop, key);
-        ///
-        throw new IllegalArgumentException("Neither the sideEffects, map, nor 
path has a " + key + "-key: " + this);
+        return Optional.<S>ofNullable(getNullableScopeValue(pop, key, 
traverser)).orElseThrow(
+                () -> new IllegalArgumentException("Neither the sideEffects, 
map, nor path has a " + key + "-key: " + this));
     }
 
     public default <S> S getNullableScopeValue(final Pop pop, final String 
key, final Traverser.Admin<?> traverser) {

Reply via email to