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 2018/04/26 15:02:24 UTC
[1/4] tinkerpop git commit: Added unit tests for Order and improved
javadoc CTR
Repository: tinkerpop
Updated Branches:
refs/heads/master 4e46f718f -> 2c3730640
Added unit tests for Order and improved javadoc CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/59545254
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/59545254
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/59545254
Branch: refs/heads/master
Commit: 59545254930c502c8acfe470dd919f36c87cf78c
Parents: 789e575
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 26 08:42:13 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 26 08:42:13 2018 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Order.java | 29 ++++++--
.../gremlin/process/traversal/OrderTest.java | 76 ++++++++++++++++++++
2 files changed, 100 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/59545254/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
index 7c3475a..3710396 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
@@ -23,10 +23,18 @@ import java.util.Map;
import java.util.Random;
/**
+ * Provides {@code Comparator} instances for ordering traversers.
+ *
* @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
*/
public enum Order implements Comparator<Object> {
+ /**
+ * Order in ascending fashion
+ *
+ * @since 3.0.0-incubating
+ */
incr {
@Override
public int compare(final Object first, final Object second) {
@@ -39,7 +47,14 @@ public enum Order implements Comparator<Object> {
public Order reversed() {
return decr;
}
- }, decr {
+ },
+
+ /**
+ * Order in descending fashion.
+ *
+ * @since 3.0.0-incubating
+ */
+ decr {
@Override
public int compare(final Object first, final Object second) {
return first instanceof Number && second instanceof Number
@@ -53,7 +68,8 @@ public enum Order implements Comparator<Object> {
}
},
/**
- * @deprecated Use {@link org.apache.tinkerpop.gremlin.structure.Column#keys};
+ * @since 3.0.0-incubating
+ * @deprecated As of release 3.1.1-incubating, replaced by {@link org.apache.tinkerpop.gremlin.structure.Column#keys}.
*/
@Deprecated
keyIncr {
@@ -68,7 +84,8 @@ public enum Order implements Comparator<Object> {
}
},
/**
- * @deprecated Use {@link org.apache.tinkerpop.gremlin.structure.Column#values};
+ * @since 3.0.0-incubating
+ * @deprecated As of release 3.1.1-incubating, replaced by {@link org.apache.tinkerpop.gremlin.structure.Column#values}.
*/
@Deprecated
valueIncr {
@@ -83,7 +100,8 @@ public enum Order implements Comparator<Object> {
}
},
/**
- * @deprecated Use {@link org.apache.tinkerpop.gremlin.structure.Column#keys};
+ * @since 3.0.0-incubating
+ * @deprecated As of release 3.1.1-incubating, replaced by {@link org.apache.tinkerpop.gremlin.structure.Column#keys}.
*/
@Deprecated
keyDecr {
@@ -98,7 +116,8 @@ public enum Order implements Comparator<Object> {
}
},
/**
- * @deprecated Use {@link org.apache.tinkerpop.gremlin.structure.Column#values};
+ * @since 3.0.0-incubating
+ * @deprecated As of release 3.1.1-incubating, replaced by {@link org.apache.tinkerpop.gremlin.structure.Column#values}.
*/
@Deprecated
valueDecr {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/59545254/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OrderTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OrderTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OrderTest.java
new file mode 100644
index 0000000..01d93ea
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OrderTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(Parameterized.class)
+public class OrderTest {
+
+ private static final SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
+
+ @Parameterized.Parameters(name = "{0}.test({1},{2})")
+ public static Iterable<Object[]> data() throws ParseException {
+ return new ArrayList<>(Arrays.asList(new Object[][]{
+ {Order.incr, Arrays.asList("b", "a", "c", "d"), Arrays.asList("a", "b", "c", "d")},
+ {Order.decr, Arrays.asList("b", "a", "c", "d"), Arrays.asList("d", "c", "b", "a")},
+ {Order.incr, Arrays.asList(formatter.parse("1-Jan-2018"), formatter.parse("1-Jan-2020"), formatter.parse("1-Jan-2008")),
+ Arrays.asList(formatter.parse("1-Jan-2008"), formatter.parse("1-Jan-2018"), formatter.parse("1-Jan-2020"))},
+ {Order.decr, Arrays.asList(formatter.parse("1-Jan-2018"), formatter.parse("1-Jan-2020"), formatter.parse("1-Jan-2008")),
+ Arrays.asList(formatter.parse("1-Jan-2020"), formatter.parse("1-Jan-2018"), formatter.parse("1-Jan-2008"))},
+ {Order.decr, Arrays.asList(100L, 1L, -1L, 0L), Arrays.asList(100L, 1L, 0L, -1L)},
+ {Order.incr, Arrays.asList(100.1f, 1.1f, -1.1f, 0.1f), Arrays.asList(-1.1f, 0.1f, 1.1f, 100.1f)},
+ {Order.decr, Arrays.asList(100.1f, 1.1f, -1.1f, 0.1f), Arrays.asList(100.1f, 1.1f, 0.1f, -1.1f)},
+ {Order.incr, Arrays.asList(100.1d, 1.1d, -1.1d, 0.1d), Arrays.asList(-1.1d, 0.1d, 1.1d, 100.1d)},
+ {Order.decr, Arrays.asList(100.1d, 1.1d, -1.1d, 0.1d), Arrays.asList(100.1d, 1.1d, 0.1d, -1.1d)},
+ {Order.incr, Arrays.asList(100L, 1L, -1L, 0L), Arrays.asList(-1L, 0L, 1L, 100L)},
+ {Order.decr, Arrays.asList(100L, 1L, -1L, 0L), Arrays.asList(100L, 1L, 0L, -1L)},
+ {Order.incr, Arrays.asList(100, 1, -1, 0), Arrays.asList(-1, 0, 1, 100)},
+ {Order.decr, Arrays.asList(100, 1, -1, 0), Arrays.asList(100, 1, 0, -1)}}));
+ }
+
+ @Parameterized.Parameter(value = 0)
+ public Order order;
+
+ @Parameterized.Parameter(value = 1)
+ public Object toBeOrdered;
+
+ @Parameterized.Parameter(value = 2)
+ public Object expectedOrder;
+
+ @Test
+ public void shouldOrder() {
+ Collections.sort((List) toBeOrdered, order);
+ assertEquals(expectedOrder, toBeOrdered);
+ }
+}
[4/4] tinkerpop git commit: Merge branch 'tp33'
Posted by sp...@apache.org.
Merge branch 'tp33'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2c373064
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2c373064
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2c373064
Branch: refs/heads/master
Commit: 2c373064021c9df5cf02906e73bdb9f37d6c9d6c
Parents: 4e46f71 c253e76
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 26 11:02:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 26 11:02:11 2018 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Compare.java | 12 ++++
.../gremlin/process/traversal/Contains.java | 4 ++
.../gremlin/process/traversal/Operator.java | 73 ++++++++++++++++++-
.../gremlin/process/traversal/Order.java | 17 ++++-
.../tinkerpop/gremlin/process/traversal/P.java | 76 ++++++++++++++++++++
.../gremlin/process/traversal/Pop.java | 10 ++-
.../gremlin/process/traversal/Scope.java | 19 +++--
.../gremlin/process/traversal/OrderTest.java | 76 ++++++++++++++++++++
8 files changed, 277 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2c373064/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
index 1f04ca6,04e7130..4fada2f
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
@@@ -49,16 -74,35 +74,35 @@@ public enum Operator implements BinaryO
return NumberHelper.div((Number) a, (Number) b);
}
},
+
+ /**
+ * Selects the smaller of the values.
+ *
+ * @since 3.0.0-incubating
+ */
min {
public Object apply(final Object a, final Object b) {
- return NumberHelper.min((Number) a, (Number) b);
+ return NumberHelper.min((Comparable) a, (Comparable) b);
}
},
+
+ /**
+ * Selects the larger of the values.
+ *
+ * @since 3.0.0-incubating
+ */
max {
public Object apply(final Object a, final Object b) {
- return NumberHelper.max((Number) a, (Number) b);
+ return NumberHelper.max((Comparable) a, (Comparable) b);
}
},
+
+ /**
+ * The new incoming value (i.e. the second value to the function) is returned unchanged result in the assignment
+ * of that value to the object of the {@code Operator}.
+ *
+ * @since 3.1.0-incubating
+ */
assign {
public Object apply(final Object a, final Object b) {
return b;
[3/4] tinkerpop git commit: Merge branch 'tp32' into tp33
Posted by sp...@apache.org.
Merge branch 'tp32' into tp33
Conflicts:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c253e768
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c253e768
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c253e768
Branch: refs/heads/master
Commit: c253e768b489cb78c0d90d85c6a933ff59e7d908
Parents: 4eeb178 a4c5a21
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 26 11:02:04 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 26 11:02:04 2018 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Compare.java | 12 ++++
.../gremlin/process/traversal/Contains.java | 4 ++
.../gremlin/process/traversal/Operator.java | 73 ++++++++++++++++++-
.../gremlin/process/traversal/Order.java | 17 ++++-
.../tinkerpop/gremlin/process/traversal/P.java | 76 ++++++++++++++++++++
.../gremlin/process/traversal/Pop.java | 10 ++-
.../gremlin/process/traversal/Scope.java | 19 +++--
.../gremlin/process/traversal/OrderTest.java | 76 ++++++++++++++++++++
8 files changed, 277 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c253e768/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c253e768/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
index dfd8bf2,3710396..847cc57
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java
@@@ -19,12 -19,14 +19,15 @@@
package org.apache.tinkerpop.gremlin.process.traversal;
import java.util.Comparator;
-import java.util.Map;
import java.util.Random;
+import org.apache.tinkerpop.gremlin.util.NumberHelper;
+
/**
+ * Provides {@code Comparator} instances for ordering traversers.
+ *
* @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
*/
public enum Order implements Comparator<Object> {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c253e768/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
index d40fe60,b2fe2b9..45bbf2e
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
@@@ -39,10 -39,8 +43,12 @@@ public enum Pop
last,
/**
* Get all the items and return them as a list.
+ *
+ * @since 3.0.0-incubating
*/
- all
+ all,
+ /**
+ * Get the items as either a list (for multiple) or an object (for singles).
+ */
+ mixed
}
[2/4] tinkerpop git commit: Improved javadoc on Gremlin enums CTR
Posted by sp...@apache.org.
Improved javadoc on Gremlin enums CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a4c5a213
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a4c5a213
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a4c5a213
Branch: refs/heads/master
Commit: a4c5a2132f8f0c7824ceddc8adefe06274767071
Parents: 5954525
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 26 09:39:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 26 09:39:52 2018 -0400
----------------------------------------------------------------------
.../gremlin/process/traversal/Compare.java | 12 ++++
.../gremlin/process/traversal/Contains.java | 4 ++
.../gremlin/process/traversal/Operator.java | 73 ++++++++++++++++++-
.../tinkerpop/gremlin/process/traversal/P.java | 76 ++++++++++++++++++++
.../gremlin/process/traversal/Pop.java | 14 +++-
.../gremlin/process/traversal/Scope.java | 19 +++--
6 files changed, 188 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/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 97b52b8..7d0d071 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
@@ -36,6 +36,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#compareTo}. 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.
+ *
+ * @since 3.0.0-incubating
*/
eq {
@Override
@@ -61,6 +63,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#equals}. 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.
+ *
+ * @since 3.0.0-incubating
*/
neq {
@Override
@@ -83,6 +87,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#compareTo}. Otherwise they are evaluated
* via {@link Comparable#compareTo(Object)}. Testing against {@link BigDecimal#compareTo} enables the compare
* operations to be a bit more forgiving with respect to comparing different number types.
+ *
+ * @since 3.0.0-incubating
*/
gt {
@Override
@@ -108,6 +114,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#compareTo}. Otherwise they are evaluated
* via {@link Comparable#compareTo(Object)}. Testing against {@link BigDecimal#compareTo} enables the compare
* operations to be a bit more forgiving with respect to comparing different number types.
+ *
+ * @since 3.0.0-incubating
*/
gte {
@Override
@@ -130,6 +138,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#compareTo}. Otherwise they are evaluated
* via {@link Comparable#compareTo(Object)}. Testing against {@link BigDecimal#compareTo} enables the compare
* operations to be a bit more forgiving with respect to comparing different number types.
+ *
+ * @since 3.0.0-incubating
*/
lt {
@Override
@@ -155,6 +165,8 @@ public enum Compare implements BiPredicate<Object, Object> {
* {@link BigDecimal} so that it can be evaluated via {@link BigDecimal#compareTo}. Otherwise they are evaluated
* via {@link Comparable#compareTo(Object)}. Testing against {@link BigDecimal#compareTo} enables the compare
* operations to be a bit more forgiving with respect to comparing different number types.
+ *
+ * @since 3.0.0-incubating
*/
lte {
@Override
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/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 2da0436..da46d0b 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
@@ -38,6 +38,8 @@ public enum Contains implements BiPredicate<Object, Collection> {
/**
* The first object is within the {@link Collection} provided in the second object.
+ *
+ * @since 3.0.0-incubating
*/
within {
@Override
@@ -48,6 +50,8 @@ public enum Contains implements BiPredicate<Object, Collection> {
/**
* The first object is not within the {@link Collection} provided in the second object.
+ *
+ * @since 3.0.0-incubating
*/
without {
@Override
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
index a52f34b..f9e0b5c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Operator.java
@@ -23,65 +23,132 @@ import java.util.Map;
import java.util.function.BinaryOperator;
/**
+ * A set of {@link BinaryOperator} instances that handle common operations for traversal steps.
+ *
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public enum Operator implements BinaryOperator<Object> {
+ /**
+ * An addition function.
+ *
+ * @since 3.0.0-incubating
+ */
sum {
public Object apply(final Object a, Object b) {
return NumberHelper.add((Number) a, (Number) b);
}
},
+
+ /**
+ * A subtraction function.
+ *
+ * @since 3.0.0-incubating
+ */
minus {
public Object apply(final Object a, final Object b) {
return NumberHelper.sub((Number) a, (Number) b);
}
},
+
+ /**
+ * A multiplication function.
+ *
+ * @since 3.0.0-incubating
+ */
mult {
public Object apply(final Object a, final Object b) {
return NumberHelper.mul((Number) a, (Number) b);
}
},
+
+ /**
+ * A division function.
+ *
+ * @since 3.0.0-incubating
+ */
div {
public Object apply(final Object a, final Object b) {
return NumberHelper.div((Number) a, (Number) b);
}
},
+
+ /**
+ * Selects the smaller of the values.
+ *
+ * @since 3.0.0-incubating
+ */
min {
public Object apply(final Object a, final Object b) {
return NumberHelper.min((Number) a, (Number) b);
}
},
+
+ /**
+ * Selects the larger of the values.
+ *
+ * @since 3.0.0-incubating
+ */
max {
public Object apply(final Object a, final Object b) {
return NumberHelper.max((Number) a, (Number) b);
}
},
+
+ /**
+ * The new incoming value (i.e. the second value to the function) is returned unchanged result in the assignment
+ * of that value to the object of the {@code Operator}.
+ *
+ * @since 3.1.0-incubating
+ */
assign {
public Object apply(final Object a, final Object b) {
return b;
}
},
+
+ /**
+ * Applies "and" to boolean values.
+ *
+ * @since 3.2.0-incubating
+ */
and {
public Object apply(final Object a, final Object b) {
return ((boolean) a) && ((boolean) b);
}
},
+
+ /**
+ * Applies "or" to boolean values.
+ *
+ * @since 3.2.0-incubating
+ */
or {
public Object apply(final Object a, final Object b) {
return ((boolean) a) || ((boolean) b);
}
},
+
+ /**
+ * Takes all objects in the second {@code Collection} and adds them to the first.
+ *
+ * @since 3.2.0-incubating
+ */
addAll {
public Object apply(final Object a, final Object b) {
if (a instanceof Map)
- ((Map) a).putAll((Map) b);
+ ((Map<?,?>) a).putAll((Map) b);
else
- ((Collection) a).addAll((Collection) b);
+ ((Collection<?>) a).addAll((Collection) b);
return a;
}
},
- //////
+
+ /**
+ * Sums and adds long values.
+ *
+ * @since 3.2.0-incubating
+ */
sumLong {
public Object apply(final Object a, final Object b) {
return (long) a + (long) b;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java
index 3b2d0c2..8454f33 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java
@@ -28,6 +28,7 @@ import java.util.function.BiPredicate;
import java.util.function.Predicate;
/**
+ * Predefined {@code Predicate} values that can be used with
* @author Marko A. Rodriguez (http://markorodriguez.com)
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
@@ -121,62 +122,137 @@ public class P<V> implements Predicate<V>, Serializable, Cloneable {
//////////////// statics
+ /**
+ * Determines if values are equal.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> eq(final V value) {
return new P(Compare.eq, value);
}
+ /**
+ * Determines if values are not equal.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> neq(final V value) {
return new P(Compare.neq, value);
}
+ /**
+ * Determines if a value is less than another.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> lt(final V value) {
return new P(Compare.lt, value);
}
+ /**
+ * Determines if a value is less than or equal to another.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> lte(final V value) {
return new P(Compare.lte, value);
}
+ /**
+ * Determines if a value is greater than another.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> gt(final V value) {
return new P(Compare.gt, value);
}
+ /**
+ * Determines if a value is greater than or equal to another.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> gte(final V value) {
return new P(Compare.gte, value);
}
+ /**
+ * Determines if a value is within (exclusive) the range of the two specified values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> inside(final V first, final V second) {
return new AndP<V>(Arrays.asList(new P(Compare.gt, first), new P(Compare.lt, second)));
}
+ /**
+ * Determines if a value is not within (exclusive) of the range of the two specified values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> outside(final V first, final V second) {
return new OrP<V>(Arrays.asList(new P(Compare.lt, first), new P(Compare.gt, second)));
}
+ /**
+ * Determines if a value is within (inclusive) of the range of the two specified values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> between(final V first, final V second) {
return new AndP<V>(Arrays.asList(new P(Compare.gte, first), new P(Compare.lt, second)));
}
+ /**
+ * Determines if a value is within the specified list of values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> within(final V... values) {
return P.within(Arrays.asList(values));
}
+ /**
+ * Determines if a value is within the specified list of values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> within(final Collection<V> value) {
return new P(Contains.within, value);
}
+ /**
+ * Determines if a value is not within the specified list of values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> without(final V... values) {
return P.without(Arrays.asList(values));
}
+ /**
+ * Deermines if a value is not within the specified list of values.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> without(final Collection<V> value) {
return new P(Contains.without, value);
}
+ /**
+ * Construct an instance of {@code P} from a {@code BiPredicate}.
+ *
+ * @since 3.0.0-incubating
+ */
public static P test(final BiPredicate biPredicate, final Object value) {
return new P(biPredicate, value);
}
+ /**
+ * The opposite of the specified {@code P}.
+ *
+ * @since 3.0.0-incubating
+ */
public static <V> P<V> not(final P<V> predicate) {
return predicate.negate();
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
index c9eab94..b2fe2b9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Pop.java
@@ -19,20 +19,28 @@
package org.apache.tinkerpop.gremlin.process.traversal;
/**
+ * Methods for extracting an item from a collection.
+ *
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public enum Pop {
/**
- * The first item in an ordered collection (i.e. <code>collection[0]</code>)
+ * The first item in an ordered collection (i.e. {@code collection[0]}).
+ *
+ * @since 3.0.0-incubating
*/
first,
/**
- * The last item in an ordered collection (i.e. <code>collection[collection.size()-1]</code>)
+ * The last item in an ordered collection (i.e. {@code collection[collection.size()-1]}).
+ *
+ * @since 3.0.0-incubating
*/
last,
/**
- * Get all the items and return them as a list
+ * Get all the items and return them as a list.
+ *
+ * @since 3.0.0-incubating
*/
all
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4c5a213/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Scope.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Scope.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Scope.java
index 11979de..c454922 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Scope.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Scope.java
@@ -19,15 +19,26 @@
package org.apache.tinkerpop.gremlin.process.traversal;
/**
- * Many {@link Step} instance can have a variable scope.
- * {@link Scope#global}: the step operates on the entire traversal.
- * {@link Scope#local}: the step operates on the current object in the step.
+ * Many {@link Step} instance can have a variable scope which alter the manner in which the step will behave in
+ * relation to how the traversers are processed.
*
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public enum Scope {
- global, local;
+ /**
+ * Informs the step to operate on the entire traversal.
+ *
+ * @since 3.0.0-incubating
+ */
+ global,
+
+ /**
+ * Informs the step to operate on the current object in the step.
+ *
+ * @since 3.0.0-incubating
+ */
+ local;
public Scope opposite() {
return global.equals(this) ? local : global;