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 2018/10/22 19:41:22 UTC

[GitHub] spmallette commented on a change in pull request #961: TINKERPOP-2061 Added with() option for traversal configuration

spmallette commented on a change in pull request #961: TINKERPOP-2061 Added with() option for traversal configuration
URL: https://github.com/apache/tinkerpop/pull/961#discussion_r227050936
 
 

 ##########
 File path: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
 ##########
 @@ -93,6 +96,39 @@ private Symbols() {
 
     /////////////////////////////
 
+    /**
+     * Provides a configuration to a traversal in the form of a key which is the same as {@code with(key, true)}. The
+     * key of the configuration must be graph provider specific and therefore a configuration could be supplied that
+     * is not known to be valid until execution.
+     *
+     * @param key the key of the configuration to apply to a traversal
+     * @return a new traversal source with the included configuration
+     * @since 3.4.0
+     */
+    public default TraversalSource with(final String key) {
+        return with(key, true);
+    }
+
+    /**
+     * Provides a configuration to a traversal in the form of a key value pair. The  key of the configuration must be
+     * graph provider specific and therefore a configuration could be supplied that is not known to be valid until
+     * execution. This is a handy shortcut for building an {@link OptionsStrategy} manually and then add with
+     * {@link #withStrategies(TraversalStrategy[])}.
+     *
+     * @param key the key of the configuration to apply to a traversal
+     * @param value the value of the configuration to apply to a traversal
+     * @return a new traversal source with the included configuration
+     * @since 3.4.0
+     */
+    public default TraversalSource with(final String key, final Object value) {
+        final Optional<OptionsStrategy> opt = getStrategies().getStrategy(OptionsStrategy.class);
+        final OptionsStrategy strategy = opt.orElse(OptionsStrategy.EMPTY);
+        final OptionsStrategy.Builder builder = OptionsStrategy.build();
+        strategy.getOptions().forEach(builder::with);
+        builder.with(key, value);
+        return withStrategies(builder.create());
+    }
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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