This is an automated email from the ASF dual-hosted git repository.
okram pushed a commit to branch tp4
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/tp4 by this push:
new ea10595 AbstractStrategy equals(), hashCode() implementations. other
minor tweaks.
ea10595 is described below
commit ea10595b1172a9ce9ae58b1aeaedb30967e7e91d
Author: Marko A. Rodriguez <[email protected]>
AuthorDate: Tue Mar 19 07:33:33 2019 -0600
AbstractStrategy equals(), hashCode() implementations. other minor tweaks.
---
.../tinkerpop/machine/strategy/AbstractStrategy.java | 10 ++++++++++
.../apache/tinkerpop/machine/strategy/Strategy.java | 4 ++--
.../tinkerpop/machine/strategy/StrategyUtil.java | 7 +++++--
.../apache/tinkerpop/language/gremlin/Traversal.java | 19 +++++++++++--------
.../org/apache/tinkerpop/language/gremlin/__.java | 4 +---
5 files changed, 29 insertions(+), 15 deletions(-)
diff --git
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/AbstractStrategy.java
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/AbstractStrategy.java
index 81118cc..fbe281d 100644
---
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/AbstractStrategy.java
+++
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/AbstractStrategy.java
@@ -27,4 +27,14 @@ public abstract class AbstractStrategy<S extends Strategy>
implements Strategy<S
public String toString() {
return this.getClass().getSimpleName();
}
+
+ @Override
+ public boolean equals(final Object other) {
+ return other.getClass().equals(this.getClass());
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getClass().hashCode();
+ }
}
diff --git
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/Strategy.java
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/Strategy.java
index 9e20518..a8a718a 100644
---
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/Strategy.java
+++
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/Strategy.java
@@ -52,9 +52,9 @@ public interface Strategy<S extends Strategy> extends
Serializable, Comparable<C
}
/**
- * The type of traversal strategy -- i.e. {@link DecorationStrategy},
{@link OptimizationStrategy}, {@link FinalizationStrategy}, or {@link
VerificationStrategy}.
+ * The type of strategy.
*
- * @return the traversal strategy category class
+ * @return the strategy category class
*/
public default Class<S> getStrategyCategory() {
return (Class) Strategy.class;
diff --git
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/StrategyUtil.java
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/StrategyUtil.java
index 48b51d7..9db77d4 100644
---
a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/StrategyUtil.java
+++
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/StrategyUtil.java
@@ -32,7 +32,11 @@ import java.util.stream.Collectors;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public class StrategyUtil {
+public final class StrategyUtil {
+
+ private StrategyUtil() {
+ // static instance
+ }
private final static List<Class<? extends Strategy>> STRATEGY_CATEGORIES =
List.of(
Strategy.DecorationStrategy.class,
@@ -51,7 +55,6 @@ public class StrategyUtil {
MultiMap.put(strategiesByCategory, s.getStrategyCategory(),
s.getClass());
});
-
//Initialize all the dependencies
strategies.forEach(strategy -> {
strategy.applyPrior().forEach(s -> {
diff --git
a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java
b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java
index 3fba0e8..7c27824 100644
---
a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java
+++
b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java
@@ -42,18 +42,21 @@ public class Traversal<C, S, E> implements Iterator<E> {
protected final Bytecode<C> bytecode;
private Compilation<C, S, E> compilation;
private Coefficient<C> currentCoefficient;
- //
+
+ // iteration helpers
private long lastCount = 0L;
private E lastObject = null;
- Traversal(final Coefficient<C> unity, final Bytecode<C> bytecode) {
- this.bytecode = bytecode;
- this.currentCoefficient = unity;
+ // used by __
+ Traversal() {
+ this.bytecode = new Bytecode<>();
+ this.currentCoefficient =
BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient<C>)
LongCoefficient.create()); // TODO: this will cause __ problems
}
- Traversal(final Bytecode<C> bytecode) {
+ // used by TraversalSource
+ Traversal(final Coefficient<C> unity, final Bytecode<C> bytecode) {
this.bytecode = bytecode;
- this.currentCoefficient =
BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient<C>)
LongCoefficient.create()); // TODO: this will cause __ problems
+ this.currentCoefficient = unity;
}
public Traversal<C, S, E> as(final String label) {
@@ -71,8 +74,8 @@ public class Traversal<C, S, E> implements Iterator<E> {
return this;
}
- public <R> Traversal<C, S, E> by(final R byObject) {
- this.bytecode.lastInstruction().addArg(byObject);
+ public Traversal<C, S, E> by(final String byString) {
+ this.bytecode.lastInstruction().addArg(byString);
return this;
}
diff --git
a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/__.java
b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/__.java
index 5d8d0c5..73db277 100644
---
a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/__.java
+++
b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/__.java
@@ -18,8 +18,6 @@
*/
package org.apache.tinkerpop.language.gremlin;
-import org.apache.tinkerpop.machine.bytecode.Bytecode;
-
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@@ -30,7 +28,7 @@ public class __ {
}
private static <C, S> Traversal<C, S, S> start() {
- return new Traversal<>(new Bytecode<>());
+ return new Traversal<>();
}
public static <C, S> Traversal<C, S, S> c(final C coefficient) {