diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitor.java index c07a5c8115f..436059d57f4 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitor.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitor.java @@ -29,7 +29,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReservedKeysVerificationStrategy; import java.util.Arrays; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; public class TraversalStrategyVisitor extends DefaultGremlinBaseVisitor { @@ -100,7 +100,7 @@ private ReservedKeysVerificationStrategy getReservedKeysVerificationStrategy(fin builder.throwException(antlr.argumentVisitor.parseBoolean(ctx.booleanArgument())); break; case ReservedKeysVerificationStrategy.KEYS: - builder.reservedKeys(new HashSet<>(Arrays.asList(antlr.genericVisitor.parseStringList(ctx.stringLiteralList())))); + builder.reservedKeys(new LinkedHashSet<>(Arrays.asList(antlr.genericVisitor.parseStringList(ctx.stringLiteralList())))); break; } }); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SeedStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SeedStrategy.java index 9ce3a8daa33..6e67aa66336 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SeedStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SeedStrategy.java @@ -26,7 +26,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy; import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -75,9 +75,9 @@ public static SeedStrategy create(final Configuration configuration) { @Override public Configuration getConfiguration() { - final Map map = new HashMap<>(); - map.put(STRATEGY, SeedStrategy.class.getCanonicalName()); + final Map map = new LinkedHashMap<>(); map.put(ID_SEED, this.seed); + map.put(STRATEGY, SeedStrategy.class.getCanonicalName()); return new MapConfiguration(map); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java index 6f34d622262..6a876e8514e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java @@ -56,7 +56,7 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -310,14 +310,14 @@ private Traversal.Admin getVertexPredicateGivenDirection(final Dir @Override public Configuration getConfiguration() { - final Map map = new HashMap<>(); + final Map map = new LinkedHashMap<>(); + map.put(CHECK_ADJACENT_VERTICES, this.checkAdjacentVertices); if (null != this.vertexCriterion) map.put(VERTICES, this.vertexCriterion); if (null != this.edgeCriterion) map.put(EDGES, this.edgeCriterion); if (null != this.vertexPropertyCriterion) map.put(VERTEX_PROPERTIES, this.vertexPropertyCriterion); - map.put(CHECK_ADJACENT_VERTICES, this.checkAdjacentVertices); return new MapConfiguration(map); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/AbstractWarningVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/AbstractWarningVerificationStrategy.java index 8bdf0ee97e8..d0aba5fc0dd 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/AbstractWarningVerificationStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/AbstractWarningVerificationStrategy.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -73,7 +73,7 @@ public void apply(final Traversal.Admin traversal) { @Override public Configuration getConfiguration() { - final Map m = new HashMap<>(2); + final Map m = new LinkedHashMap<>(2); m.put(THROW_EXCEPTION, this.throwException); m.put(LOG_WARNING, this.logWarning); return new MapConfiguration(m); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ReservedKeysVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ReservedKeysVerificationStrategy.java index 9d0d25f65c9..460a05573d8 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ReservedKeysVerificationStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ReservedKeysVerificationStrategy.java @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; @@ -48,7 +48,7 @@ public class ReservedKeysVerificationStrategy extends AbstractWarningVerificationStrategy { public static final String KEYS = "keys"; - private static final Set DEFAULT_RESERVED_KEYS = new HashSet<>(Arrays.asList("id", "label")); + private static final Set DEFAULT_RESERVED_KEYS = new LinkedHashSet<>(Arrays.asList("id", "label")); private final Set reservedKeys; private ReservedKeysVerificationStrategy(final Builder builder) { @@ -79,7 +79,7 @@ void verify(final Traversal.Admin traversal) throws VerificationException public static ReservedKeysVerificationStrategy create(final Configuration configuration) { return build() .reservedKeys(configuration.getList(KEYS, new ArrayList<>(DEFAULT_RESERVED_KEYS)). - stream().map(Object::toString).collect(Collectors.toSet())) + stream().map(Object::toString).collect(Collectors.toCollection(LinkedHashSet::new))) .throwException(configuration.getBoolean(THROW_EXCEPTION, false)) .logWarning(configuration.getBoolean(LOG_WARNING, false)).create(); } @@ -101,7 +101,7 @@ public final static class Builder extends AbstractWarningVerificationStrategy.Bu private Builder() {} public Builder reservedKeys(final Set keys) { - reservedKeys = keys; + this.reservedKeys = new LinkedHashSet<>(keys); return this; } diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitorTest.java index dd9271a0a13..9a60e836e20 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitorTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalStrategyVisitorTest.java @@ -36,7 +36,7 @@ import org.junit.runners.Parameterized; import java.util.Arrays; -import java.util.HashSet; +import java.util.LinkedHashSet; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.hasLabel; @@ -68,7 +68,7 @@ public static Iterable generateTestParameters() { {"new ReservedKeysVerificationStrategy()", ReservedKeysVerificationStrategy.build().create()}, {"new ReservedKeysVerificationStrategy(logWarning: true, throwException: true)", ReservedKeysVerificationStrategy.build().logWarning(true).throwException(true).create()}, {"new ReservedKeysVerificationStrategy(logWarning: true, throwException: false)", ReservedKeysVerificationStrategy.build().logWarning(true).create()}, - {"new ReservedKeysVerificationStrategy(keys: ['a','b'])", ReservedKeysVerificationStrategy.build().reservedKeys(new HashSet<>(Arrays.asList("a", "b"))).create()}, + {"new ReservedKeysVerificationStrategy(keys: ['a','b'])", ReservedKeysVerificationStrategy.build().reservedKeys(new LinkedHashSet<>(Arrays.asList("a", "b"))).create()}, {"new SubgraphStrategy(vertices: hasLabel('person'))", SubgraphStrategy.build().vertices(hasLabel("person")).create()}, {"new SubgraphStrategy(vertices: hasLabel('person'), edges: hasLabel('knows'), vertexProperties: has('time', between(1234, 4321)), checkAdjacentVertices: true)", SubgraphStrategy.build().vertices(hasLabel("person")).edges(hasLabel("knows")).vertexProperties(has("time", P.between(1234, 4321))).checkAdjacentVertices(true).create()}, });