You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/08/14 22:02:21 UTC
[1/8] incubator-tinkerpop git commit: Update javadoc on ResultSet.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master ca2d11299 -> 9af612046
Update javadoc on ResultSet.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e17235b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e17235b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e17235b3
Branch: refs/heads/master
Commit: e17235b398befbb03d3b9b3bf242c407c8a7564d
Parents: e4352a4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 13:40:39 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 13:40:39 2015 -0400
----------------------------------------------------------------------
.../org/apache/tinkerpop/gremlin/driver/ResultSet.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e17235b3/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
index e7b2b0c..05f6fc0 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
@@ -37,9 +37,11 @@ import java.util.stream.StreamSupport;
* is stored in an {@link Result} which can be used to retrieve the item once it is on the client side.
* <p/>
* Note that a {@code ResultSet} is a forward-only stream only so depending on how the methods are called and
- * interacted with, it is possible to return partial bits of total response (e.g. calling {@link #one()} followed
+ * interacted with, it is possible to return partial bits of the total response (e.g. calling {@link #one()} followed
* by {@link #all()} will make it so that the {@link List} of results returned from {@link #all()} have one
* {@link Result} missing from the total set as it was already retrieved by {@link #one}.
+ * <p/>
+ * This class is not thread-safe.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
@@ -108,11 +110,15 @@ public final class ResultSet implements Iterable<Result> {
* Stream items with a blocking iterator.
*/
public Stream<Result> stream() {
- return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator(), Spliterator.IMMUTABLE | Spliterator.SIZED), false);
+ return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator(),
+ Spliterator.IMMUTABLE | Spliterator.SIZED), false);
}
/**
- * Returns a blocking iterator of the items streaming from the server to the client.
+ * Returns a blocking iterator of the items streaming from the server to the client. This {@link Iterator} will
+ * consume results as they arrive and leaving the {@code ResultSet} empty when complete.
+ * <p/>
+ * The returned {@link Iterator} does not support the {@link Iterator#remove} method.
*/
@Override
public Iterator<Result> iterator() {
[6/8] incubator-tinkerpop git commit: Clean up javadoc a bit in
strategies.
Posted by sp...@apache.org.
Clean up javadoc a bit in strategies.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/197036c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/197036c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/197036c8
Branch: refs/heads/master
Commit: 197036c82de38edf4e725d5eea5c8593298f2573
Parents: 50f7eb4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 15:48:01 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 15:48:01 2015 -0400
----------------------------------------------------------------------
.../strategy/decoration/ConjunctionStrategy.java | 3 ++-
.../strategy/decoration/ElementIdStrategy.java | 2 +-
.../strategy/finalization/EngineDependentStrategy.java | 13 +++++++++----
.../optimization/AdjacentToIncidentStrategy.java | 6 +++---
.../strategy/optimization/DedupBijectionStrategy.java | 5 +++--
.../strategy/optimization/IdentityRemovalStrategy.java | 2 +-
.../optimization/IncidentToAdjacentStrategy.java | 6 +++---
.../strategy/optimization/MatchPredicateStrategy.java | 5 +++--
.../strategy/optimization/RangeByIsCountStrategy.java | 2 +-
.../verification/LambdaRestrictionStrategy.java | 7 ++++---
.../traversal/traverser/TraverserRequirement.java | 8 ++++++--
11 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConjunctionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConjunctionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConjunctionStrategy.java
index 48ae008..7bf7177 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConjunctionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConjunctionStrategy.java
@@ -35,7 +35,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import java.util.Set;
/**
- * ConjunctionStrategy rewrites the binary conjunction form of <code>a.and().b</code> into a {@link AndStep} of <code>and(a,b)</code> (likewise for {@link OrStep}.
+ * ConjunctionStrategy rewrites the binary conjunction form of {@code a.and().b} into a {@link AndStep} of
+ * {@code and(a,b)} (likewise for {@link OrStep}).
* <p/>
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java
index 91c6a12..2eca211 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java
@@ -48,7 +48,7 @@ import java.util.function.Supplier;
* thus simulating that capability.
* <p/>
* By default, when an identifier is not supplied by the user, newly generated identifiers are {@link UUID} objects.
- * This behavior can be overriden by setting the {@link Builder#idMaker(Supplier)}.
+ * This behavior can be overridden by setting the {@link Builder#idMaker(Supplier)}.
* <p/>
* Unless otherwise specified the identifier is stored in the {@code __id} property. This can be changed by setting
* the {@link Builder#idPropertyKey(String)}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/EngineDependentStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/EngineDependentStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/EngineDependentStrategy.java
index 4104c7a..27b9ce0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/EngineDependentStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/EngineDependentStrategy.java
@@ -18,19 +18,24 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine.Type;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.step.EngineDependent;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
/**
- * A {@link org.apache.tinkerpop.gremlin.process.traversal.Step} can extend {@link EngineDependent}.
- * If it does, that means that the steps internal logic is modulated by whether the execution is via {@link org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine.Type#STANDARD} or {@link org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine.Type#COMPUTER}.
- * EngineDependentStrategy simply locates all engine dependent steps and provides the respective {@link org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine}.
+ * A {@link Step} can extend {@link EngineDependent}. If it does, that means that the steps internal logic is
+ * modulated by whether the execution is via {@link Type#STANDARD} or {@link Type#COMPUTER}.
+ * {@code EngineDependentStrategy} simply locates all engine dependent steps and provides the respective
+ * {@link TraversalEngine}.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class EngineDependentStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy> implements TraversalStrategy.FinalizationStrategy {
+public final class EngineDependentStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy>
+ implements TraversalStrategy.FinalizationStrategy {
private static final EngineDependentStrategy INSTANCE = new EngineDependentStrategy();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
index a8b11c9..c091805 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java
@@ -41,9 +41,9 @@ import java.util.Set;
/**
* This strategy looks for vertex- and value-emitting steps followed by a {@link CountGlobalStep} and replaces the
- * pattern with an edge- or property-emitting step followed by a <code>CountGlobalStep</code>. Furthermore, if a vertex-
- * or value-emitting step is the last step in a <code>.has(traversal)</code>, <code>.and(traversal, ...)</code> or
- * <code>.or(traversal, ...)</code> child traversal, it is replaced by an appropriate edge- or property-emitting step.
+ * pattern with an edge- or property-emitting step followed by a {@code CountGlobalStep}. Furthermore, if a vertex-
+ * or value-emitting step is the last step in a {@code .has(traversal)}, {@code .and(traversal, ...)} or
+ * {@code .or(traversal, ...)} child traversal, it is replaced by an appropriate edge- or property-emitting step.
* <p/>
*
* @author Daniel Kuppitz (http://gremlin.guru)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
index a26bda6..712184d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
@@ -32,8 +32,9 @@ import java.util.List;
import java.util.Set;
/**
- * DedupBijectionStrategy does deduplication prior to a non-mutating bijective step if there is no <code>by()</code>-modulation on <code>dedup()</code>.
- * Given that {@link DedupGlobalStep} reduces the number of objects in the stream, it is cheaper to dedup prior.
+ * {@code DedupBijectionStrategy} does deduplication prior to a non-mutating bijective step if there is no
+ * {@code by()}-modulation on {@code dedup()}. Given that {@link DedupGlobalStep} reduces the number of
+ * objects in the stream, it is cheaper to dedup prior.
* <p/>
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IdentityRemovalStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IdentityRemovalStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IdentityRemovalStrategy.java
index 8c106f9..142e525 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IdentityRemovalStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IdentityRemovalStrategy.java
@@ -27,7 +27,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversal
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
/**
- * IdentityRemovalStrategy looks for {@link IdentityStep} instances and removes them.
+ * {@code IdentityRemovalStrategy} looks for {@link IdentityStep} instances and removes them.
* If the identity step is labeled, its labels are added to the previous step.
* If the identity step is labeled and its the first step, in the traversal, it stays.
* <p/>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
index 5111e74..de05aa9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
@@ -38,12 +38,12 @@ import java.util.HashSet;
import java.util.Set;
/**
- * This strategy looks for <code>.outE().inV()</code>, <code>.inE().outV()</code> and <code>.bothE().otherV()</code>
- * and replaces these step sequences with <code>.out()</code>, <code>.in()</code> or <code>.both()</code> respectively.
+ * This strategy looks for {@code .outE().inV()}, {@code .inE().outV()} and {@code .bothE().otherV()}
+ * and replaces these step sequences with {@code .out()}, {@code .in()} or {@code .both()} respectively.
* The strategy won't modify the traversal if:
* <ul>
* <li>the edge step is labeled</li>
- * <li>the traversal contains a <code>path</code> step</li>
+ * <li>the traversal contains a {@code path} step</li>
* <li>the traversal contains a lambda step</li>
* </ul>
* <p/>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
index 3a41092..5a8a03a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
@@ -38,8 +38,9 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
- * MatchWhereStrategy will fold any post-<code>where()</code> step that maintains a traversal constraint into <code>match()</code>.
- * {@link MatchStep} is intelligent with traversal constraint applications and thus, can more efficiently use the constraint of {@link WhereTraversalStep} or {@link WherePredicateStep}.
+ * MatchWhereStrategy will fold any post-{@code where()} step that maintains a traversal constraint into
+ * {@code match()}. {@link MatchStep} is intelligent with traversal constraint applications and thus, can more
+ * efficiently use the constraint of {@link WhereTraversalStep} or {@link WherePredicateStep}.
* <p/>
* <p/>
*
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
index 5bbc224..1933ced 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
@@ -44,7 +44,7 @@ import java.util.function.BiPredicate;
/**
* This strategy optimizes any occurrence of {@link CountGlobalStep} followed by an {@link IsStep}. The idea is to limit
* the number of incoming elements in a way that it's enough for the {@link IsStep} to decide whether it evaluates
- * <code>true</code> or <code>false</code>. If the traversal already contains a user supplied limit, the strategy won't
+ * {@code true} or {@code false}. If the traversal already contains a user supplied limit, the strategy won't
* modify it.
*
* @author Daniel Kuppitz (http://gremlin.guru)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
index e614cc5..837b6db 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
@@ -28,9 +28,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversal
import java.util.Comparator;
/**
- * LambdaRestrictionStrategy does not allow lambdas to be used in a {@link Traversal}.
- * The contents of a lambda can not be analyzed/optimized and thus, reduces the ability of other {@link TraversalStrategy} instances to reason about the traversal.
- * This strategy is not activated by default. However, graph system vendors may choose to make this a default strategy in order to ensure their respective strategies are better able to operate.
+ * {@code LambdaRestrictionStrategy} does not allow lambdas to be used in a {@link Traversal}. The contents of a lambda
+ * cannot be analyzed/optimized and thus, reduces the ability of other {@link TraversalStrategy} instances to reason
+ * about the traversal. This strategy is not activated by default. However, graph system vendors may choose to make
+ * this a default strategy in order to ensure their respective strategies are better able to operate.
* <p/>
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/197036c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java
index 6fd49f1..8d6c7c8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java
@@ -18,10 +18,14 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+
/**
- * A {@link TraverserRequirement} is a list of requirements that a {@link org.apache.tinkerpop.gremlin.process.traversal.Traversal} requires of a {@link org.apache.tinkerpop.gremlin.process.traversal.Traverser}.
+ * A {@link TraverserRequirement} is a list of requirements that a {@link Traversal} requires of a {@link Traverser}.
* The less requirements, the simpler the traverser can be (both in terms of space and time constraints).
- * Every {@link org.apache.tinkerpop.gremlin.process.traversal.Step} provides its specific requirements via {@link org.apache.tinkerpop.gremlin.process.traversal.Step#getRequirements()}.
+ * Every {@link Step} provides its specific requirements via {@link Step#getRequirements()}.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
[5/8] incubator-tinkerpop git commit: Update javadoc on Direction.
Posted by sp...@apache.org.
Update javadoc on Direction.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/50f7eb43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/50f7eb43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/50f7eb43
Branch: refs/heads/master
Commit: 50f7eb43c87ff181a43cf80e97682f96ae2b8a54
Parents: bccac41
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 15:13:35 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 15:13:35 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/Direction.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/50f7eb43/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Direction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Direction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Direction.java
index b52b83b..d412e24 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Direction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Direction.java
@@ -30,11 +30,28 @@ package org.apache.tinkerpop.gremlin.structure;
* {@link Vertex}.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
*/
public enum Direction {
- OUT, IN, BOTH;
+ /**
+ * Refers to an outgoing direction.
+ */
+ OUT,
+
+ /**
+ * Refers to an incoming direction.
+ */
+ IN,
+ /**
+ * Refers to either direction ({@link #IN} or {@link #OUT}).
+ */
+ BOTH;
+
+ /**
+ * The actual direction of an {@link Edge} may only be {@link #IN} or {@link #OUT}, as defined in this array.
+ */
public static final Direction[] proper = new Direction[]{OUT, IN};
/**
[3/8] incubator-tinkerpop git commit: Update javadoc on Compare.
Posted by sp...@apache.org.
Update javadoc on Compare.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/ba1cdf36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/ba1cdf36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/ba1cdf36
Branch: refs/heads/master
Commit: ba1cdf3683a4a04c16f9755f6edbd0436853aef1
Parents: 35b4b91
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 14:55:17 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 14:55:17 2015 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Compare.java | 88 +++++++++++++++++---
1 file changed, 76 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ba1cdf36/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java
index c4b68fa..aad8371 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java
@@ -25,9 +25,16 @@ import java.util.function.BiPredicate;
* {@code >}, {@code >=}, {@code <}, {@code <=} to the second argument.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
*/
public enum Compare implements BiPredicate<Object, Object> {
-
+ /**
+ * Evaluates if the first object is equal to the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Object#equals(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
eq {
@Override
public boolean test(final Object first, final Object second) {
@@ -37,21 +44,45 @@ public enum Compare implements BiPredicate<Object, Object> {
: first.equals(second));
}
+ /**
+ * The negative of {@code eq} is {@link #neq}.
+ */
@Override
public Compare negate() {
return neq;
}
- }, neq {
+ },
+
+ /**
+ * Evaluates if the first object is not equal to the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Object#equals(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
+ neq {
@Override
public boolean test(final Object first, final Object second) {
return !eq.test(first, second);
}
+ /**
+ * The negative of {@code neq} is {@link #eq}
+ */
@Override
public Compare negate() {
return eq;
}
- }, gt {
+ },
+
+ /**
+ * Evaluates if the first object is greater than the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Comparable#compareTo(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
+ gt {
@Override
public boolean test(final Object first, final Object second) {
return null != first && null != second && (
@@ -60,21 +91,45 @@ public enum Compare implements BiPredicate<Object, Object> {
: ((Comparable) first).compareTo(second) > 0);
}
+ /**
+ * The negative of {@code gt} is {@link #lte}.
+ */
@Override
public Compare negate() {
return lte;
}
- }, gte {
+ },
+
+ /**
+ * Evaluates if the first object is greater-equal to the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Comparable#compareTo(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
+ gte {
@Override
public boolean test(final Object first, final Object second) {
return null == first ? null == second : (null != second && !lt.test(first, second));
}
+ /**
+ * The negative of {@code gte} is {@link #lt}.
+ */
@Override
public Compare negate() {
return lt;
}
- }, lt {
+ },
+
+ /**
+ * Evaluates if the first object is less than the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Comparable#compareTo(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
+ lt {
@Override
public boolean test(final Object first, final Object second) {
return null != first && null != second && (
@@ -83,16 +138,31 @@ public enum Compare implements BiPredicate<Object, Object> {
: ((Comparable) first).compareTo(second) < 0);
}
+ /**
+ * The negative of {@code lt} is {@link #gte}.
+ */
@Override
public Compare negate() {
return gte;
}
- }, lte {
+ },
+
+ /**
+ * Evaluates if the first object is less-equal to the second. If both are of type {@link Number} but not of the
+ * same class (i.e. double for the first object and long for the second object) both values are cast to
+ * {@link Number} so that it can be evaluated via {@link Number#doubleValue()}. Otherwise they are evaluated
+ * via {@link Comparable#compareTo(Object)}. Testing against {@link Number#doubleValue()} enables the compare
+ * operations to be a bit more forgiving with respect to comparing different number types.
+ */
+ lte {
@Override
public boolean test(final Object first, final Object second) {
return null == first ? null == second : (null != second && !gt.test(first, second));
}
+ /**
+ * The negative of {@code lte} is {@link #gt}.
+ */
@Override
public Compare negate() {
return gt;
@@ -100,12 +170,6 @@ public enum Compare implements BiPredicate<Object, Object> {
};
/**
- * {@inheritDoc}
- */
- /*@Override
- public abstract boolean test(final Object first, final Object second);*/
-
- /**
* Produce the opposite representation of the current {@code Compare} enum.
*/
@Override
[2/8] incubator-tinkerpop git commit: Update javadoc on Result.
Posted by sp...@apache.org.
Update javadoc on Result.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/35b4b917
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/35b4b917
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/35b4b917
Branch: refs/heads/master
Commit: 35b4b9174461e6428edad8a629019b61ee697092
Parents: e17235b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 13:50:04 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 13:50:04 2015 -0400
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/driver/Result.java | 64 +++++++++++++++++++-
1 file changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/35b4b917/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java
index f65f2be..0ea13f0 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Result.java
@@ -44,26 +44,54 @@ public final class Result {
this.resultObject = responseData;
}
+ /**
+ * Gets the result item by coercing it to a {@code String} via {@code toString()}.
+ */
public String getString() {
return resultObject.toString();
}
+ /**
+ * Gets the result item by coercing it to an {@code int}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code int}.
+ */
public int getInt() {
return Integer.parseInt(resultObject.toString());
}
+ /**
+ * Gets the result item by coercing it to an {@code byte}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code byte}.
+ */
public byte getByte() {
return Byte.parseByte(resultObject.toString());
}
+ /**
+ * Gets the result item by coercing it to an {@code short}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code short}.
+ */
public short getShort() {
return Short.parseShort(resultObject.toString());
}
+ /**
+ * Gets the result item by coercing it to an {@code long}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code long}.
+ */
public long getLong() {
return Long.parseLong(resultObject.toString());
}
+ /**
+ * Gets the result item by coercing it to an {@code float}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code float}.
+ */
public float getFloat() {
return Float.parseFloat(resultObject.toString());
}
@@ -72,42 +100,74 @@ public final class Result {
return Double.parseDouble(resultObject.toString());
}
+ /**
+ * Gets the result item by coercing it to an {@code boolean}.
+ *
+ * @throws NumberFormatException if the value is not parsable as an {@code boolean}.
+ */
public boolean getBoolean() {
return Boolean.parseBoolean(resultObject.toString());
}
+ /**
+ * Determines if the result item is null or not. This is often a good check prior to calling other methods to
+ * get the object as they could throw an unexpected {@link NullPointerException} if the result item is
+ * {@code null}.
+ */
public boolean isNull() {
return null == resultObject;
}
+ /**
+ * Gets the result item by casting it to a {@link Vertex}.
+ */
public Vertex getVertex() {
return (Vertex) resultObject;
}
-
+ /**
+ * Gets the result item by casting it to an {@link Edge}.
+ */
public Edge getEdge() {
return (Edge) resultObject;
}
-
+ /**
+ * Gets the result item by casting it to an {@link Element}.
+ */
public Element getElement() {
return (Element) resultObject;
}
+ /**
+ * Gets the result item by casting it to a {@link Path}.
+ */
public Path getPath() {
return (Path) resultObject;
}
+ /**
+ * Gets the result item by casting it to a {@link Property}.
+ */
public <V> Property<V> getProperty() {
return (Property<V>) resultObject;
}
+ /**
+ * Gets the result item by casting it to a {@link VertexProperty}.
+ */
public <V> VertexProperty<V> getVertexProperty() {
return (VertexProperty<V>) resultObject;
}
+ /**
+ * Gets the result item by casting it to the specified {@link Class}.
+ */
public <T> T get(final Class<? extends T> clazz) {
return clazz.cast(this.resultObject);
}
+ /**
+ * Gets the result item.
+ */
public Object getObject() {
return this.resultObject;
}
[8/8] incubator-tinkerpop git commit: Removed DedupBijectionStrategy
again - came in accidentally after merge from tp30.
Posted by sp...@apache.org.
Removed DedupBijectionStrategy again - came in accidentally after merge from tp30.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/9af61204
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/9af61204
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/9af61204
Branch: refs/heads/master
Commit: 9af61204606086e76d574afce356c44cd4197067
Parents: a13706f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 15:53:35 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 15:53:35 2015 -0400
----------------------------------------------------------------------
.../optimization/DedupBijectionStrategy.java | 90 --------------------
1 file changed, 90 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9af61204/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
deleted file mode 100644
index 712184d..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Step;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * {@code DedupBijectionStrategy} does deduplication prior to a non-mutating bijective step if there is no
- * {@code by()}-modulation on {@code dedup()}. Given that {@link DedupGlobalStep} reduces the number of
- * objects in the stream, it is cheaper to dedup prior.
- * <p/>
- *
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- * @author Daniel Kuppitz (http://gremlin.guru)
- * @example <pre>
- * __.order().dedup() // is replaced by __.dedup().order()
- * </pre>
- */
-public final class DedupBijectionStrategy extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy> implements TraversalStrategy.OptimizationStrategy {
-
- private static final DedupBijectionStrategy INSTANCE = new DedupBijectionStrategy();
- private static final Set<Class<? extends OptimizationStrategy>> PRIORS = new HashSet<>();
-
- static {
- PRIORS.add(IdentityRemovalStrategy.class);
- }
-
-
- private DedupBijectionStrategy() {
- }
-
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal) {
- if (!TraversalHelper.hasStepOfClass(DedupGlobalStep.class, traversal))
- return;
-
- final List<Step> steps = traversal.getSteps();
- boolean exchangeable = false;
- for (int i = steps.size() - 1; i >= 0; i--) {
- final Step curr = steps.get(i);
- if (exchangeable) {
- if (curr instanceof OrderGlobalStep) {
- final Step next = curr.getNextStep();
- traversal.removeStep(next);
- traversal.addStep(i, next);
- }
- exchangeable = curr instanceof IdentityStep;
- } else {
- exchangeable = curr instanceof DedupGlobalStep && ((DedupGlobalStep) curr).getLocalChildren().isEmpty();
- }
- }
- }
-
- @Override
- public Set<Class<? extends OptimizationStrategy>> applyPrior() {
- return PRIORS;
- }
-
- public static DedupBijectionStrategy instance() {
- return INSTANCE;
- }
-}
[7/8] incubator-tinkerpop git commit: Merge remote-tracking branch
'origin/tp30'
Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/tp30'
Conflicts:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/DedupBijectionStrategy.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/a13706ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a13706ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a13706ff
Branch: refs/heads/master
Commit: a13706ffb2a442a81b64e29a92cc495b3412100e
Parents: ca2d112 197036c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 15:52:52 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 15:52:52 2015 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Compare.java | 88 ++++++++++++++++---
.../gremlin/process/traversal/Contains.java | 12 ++-
.../decoration/ConjunctionStrategy.java | 3 +-
.../strategy/decoration/ElementIdStrategy.java | 2 +-
.../finalization/EngineDependentStrategy.java | 13 ++-
.../AdjacentToIncidentStrategy.java | 6 +-
.../optimization/DedupBijectionStrategy.java | 90 ++++++++++++++++++++
.../optimization/IdentityRemovalStrategy.java | 2 +-
.../IncidentToAdjacentStrategy.java | 6 +-
.../optimization/MatchPredicateStrategy.java | 5 +-
.../optimization/RangeByIsCountStrategy.java | 2 +-
.../verification/LambdaRestrictionStrategy.java | 7 +-
.../traverser/TraverserRequirement.java | 8 +-
.../tinkerpop/gremlin/structure/Direction.java | 19 ++++-
.../gremlin/process/traversal/ContainsTest.java | 68 +++++++++++++++
.../apache/tinkerpop/gremlin/driver/Result.java | 64 +++++++++++++-
.../tinkerpop/gremlin/driver/ResultSet.java | 12 ++-
17 files changed, 366 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a13706ff/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/TraverserRequirement.java
----------------------------------------------------------------------
[4/8] incubator-tinkerpop git commit: Add javadoc and tests for
Contains.
Posted by sp...@apache.org.
Add javadoc and tests for Contains.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/bccac41d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/bccac41d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/bccac41d
Branch: refs/heads/master
Commit: bccac41d800167e7e1d8730cd33166231fe37f28
Parents: ba1cdf3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 14 15:07:36 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 14 15:07:36 2015 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Contains.java | 12 +++-
.../gremlin/process/traversal/ContainsTest.java | 68 ++++++++++++++++++++
2 files changed, 78 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bccac41d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java
index 5e4e804..2da0436 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java
@@ -22,7 +22,7 @@ import java.util.Collection;
import java.util.function.BiPredicate;
/**
- * {@link Contains} is a {@link java.util.function.BiPredicate} that evaluates whether the first object is contained within (or not
+ * {@link Contains} is a {@link BiPredicate} that evaluates whether the first object is contained within (or not
* within) the second collection object. For example:
* <p/>
* <pre>
@@ -36,12 +36,20 @@ import java.util.function.BiPredicate;
*/
public enum Contains implements BiPredicate<Object, Collection> {
+ /**
+ * The first object is within the {@link Collection} provided in the second object.
+ */
within {
@Override
public boolean test(final Object first, final Collection second) {
return second.contains(first);
}
- }, without {
+ },
+
+ /**
+ * The first object is not within the {@link Collection} provided in the second object.
+ */
+ without {
@Override
public boolean test(final Object first, final Collection second) {
return !second.contains(first);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bccac41d/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/ContainsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/ContainsTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/ContainsTest.java
new file mode 100644
index 0000000..6d9ea38
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/ContainsTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(Parameterized.class)
+public class ContainsTest {
+
+ @Parameterized.Parameters(name = "{0}({1},{2}) = {3}")
+ public static Iterable<Object[]> data() {
+ return new ArrayList<>(Arrays.asList(new Object[][]{
+ {Contains.within, 10, Arrays.asList(1, 2, 3, 4, 10), true},
+ {Contains.without, 10, Arrays.asList(1, 2, 3, 4, 10), false},
+ {Contains.within, 10, Collections.emptyList(), false},
+ {Contains.without, 10, Collections.emptyList(), true},
+ {Contains.within, 100, Arrays.asList(1, 2, 3, 4, 10), false},
+ {Contains.without, 10l, Arrays.asList(1, 2, 3, 4, 10), true}, // no forgiveness
+ {Contains.within, "test", Arrays.asList(1, 2, 3, "test", 10), true},
+ {Contains.without, "testing", Arrays.asList(1, 2, 3, "test", 10), true}
+ }));
+ }
+
+ @Parameterized.Parameter(value = 0)
+ public Contains contains;
+
+ @Parameterized.Parameter(value = 1)
+ public Object first;
+
+ @Parameterized.Parameter(value = 2)
+ public Collection collection;
+
+ @Parameterized.Parameter(value = 3)
+ public boolean expected;
+
+ @Test
+ public void shouldTest() {
+ assertEquals(expected, contains.test(first, collection));
+ }
+}