[tinkerpop] 01/01: Implemented EdgeLabelVerificationStrategy
This is an automated email from the ASF dual-hosted git repository. dkuppitz pushed a commit to branch TINKERPOP-2191 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git commit 0769976c267183ffb9aa22ab9a379d7163e70d84 Author: Daniel Kuppitz AuthorDate: Thu Mar 14 15:05:09 2019 -0700 Implemented EdgeLabelVerificationStrategy --- CHANGELOG.asciidoc | 2 +- docs/src/upgrade/release-3.3.x.asciidoc| 38 + .../tinkerpop/gremlin/jsr223/CoreImports.java | 2 + .../EdgeLabelVerificationStrategy.java | 131 ++ .../structure/io/graphson/GraphSONModule.java | 5 + .../gremlin/structure/io/gryo/GryoVersion.java | 7 +- .../EdgeLabelVerificationStrategyTest.java | 188 + 7 files changed, 370 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 88df8ad..106761a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima === TinkerPop 3.3.7 (Release Date: NOT OFFICIALLY RELEASED YET) * Ensure `gremlin.sh` works when directories contain spaces - +* Implemented `EdgeLabelVerificationStrategy` [[release-3-3-6]] === TinkerPop 3.3.6 (Release Date: March 18, 2019) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index c1911d3..a5ece72 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -27,6 +27,44 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima Please see the link:https://github.com/apache/tinkerpop/blob/3.3.7/CHANGELOG.asciidoc#release-3-3-7[changelog] for a complete list of all the modifications that are part of this release. +=== Upgrading for Providers + + Detection of Anti-Patterns + +This release adds a strategy named `EdgeLabelVerificationStrategy`. The strategy will not be added by default to the traversal source, however, providers can add it explicitly to encourage (or enforce) +users to always specify at least one edge label. `EdgeLabelVerificationStrategy` can be configured to either throw an exception if no edge label was specified, log a warning or do both. + +[source,text] + +gremlin> // throw an exception if edge label was not specified +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().throwException().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +Type ':help' or ':h' for help. +Display stack trace? [yN] + + +[source,text] + +gremlin> // log a warning if edge label was not specified (Log4j has to be configured properly) +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().logWarning().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +WARN org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy - The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +==>v[3] +==>v[2] +==>v[4] + + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-2191[TINKERPOP-2191] + == TinkerPop 3.3.6 *Release Date: March 18, 2019* diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 576d0de..e298951 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -86,6 +86,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Orde import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; @@ -241,6 +242,7 @@ public final class CoreImports { CLASS_IMPORTS.add(LambdaRestrictionStrategy.class); CLASS_IMPORTS.add(ReadOnlyStrategy.class);
[tinkerpop] 01/01: Implemented EdgeLabelVerificationStrategy
This is an automated email from the ASF dual-hosted git repository. dkuppitz pushed a commit to branch TINKERPOP-2191 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git commit 402e5401ddd5e4898013b972842d0db781664147 Author: Daniel Kuppitz AuthorDate: Thu Mar 14 15:05:09 2019 -0700 Implemented EdgeLabelVerificationStrategy --- CHANGELOG.asciidoc | 2 +- docs/src/upgrade/release-3.3.x.asciidoc| 38 + .../tinkerpop/gremlin/jsr223/CoreImports.java | 2 + .../EdgeLabelVerificationStrategy.java | 130 ++ .../structure/io/graphson/GraphSONModule.java | 5 + .../gremlin/structure/io/gryo/GryoVersion.java | 7 +- .../EdgeLabelVerificationStrategyTest.java | 188 + 7 files changed, 369 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 88df8ad..106761a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima === TinkerPop 3.3.7 (Release Date: NOT OFFICIALLY RELEASED YET) * Ensure `gremlin.sh` works when directories contain spaces - +* Implemented `EdgeLabelVerificationStrategy` [[release-3-3-6]] === TinkerPop 3.3.6 (Release Date: March 18, 2019) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index c1911d3..a5ece72 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -27,6 +27,44 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima Please see the link:https://github.com/apache/tinkerpop/blob/3.3.7/CHANGELOG.asciidoc#release-3-3-7[changelog] for a complete list of all the modifications that are part of this release. +=== Upgrading for Providers + + Detection of Anti-Patterns + +This release adds a strategy named `EdgeLabelVerificationStrategy`. The strategy will not be added by default to the traversal source, however, providers can add it explicitly to encourage (or enforce) +users to always specify at least one edge label. `EdgeLabelVerificationStrategy` can be configured to either throw an exception if no edge label was specified, log a warning or do both. + +[source,text] + +gremlin> // throw an exception if edge label was not specified +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().throwException().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +Type ':help' or ':h' for help. +Display stack trace? [yN] + + +[source,text] + +gremlin> // log a warning if edge label was not specified (Log4j has to be configured properly) +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().logWarning().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +WARN org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy - The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +==>v[3] +==>v[2] +==>v[4] + + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-2191[TINKERPOP-2191] + == TinkerPop 3.3.6 *Release Date: March 18, 2019* diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 576d0de..e298951 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -86,6 +86,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Orde import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; @@ -241,6 +242,7 @@ public final class CoreImports { CLASS_IMPORTS.add(LambdaRestrictionStrategy.class); CLASS_IMPORTS.add(ReadOnlyStrategy.class);
[tinkerpop] 01/01: Implemented EdgeLabelVerificationStrategy
This is an automated email from the ASF dual-hosted git repository. dkuppitz pushed a commit to branch TINKERPOP-2191 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git commit ce7c5ea4503c651210cc7e4dfb444eadb0df9099 Author: Daniel Kuppitz AuthorDate: Thu Mar 14 15:05:09 2019 -0700 Implemented EdgeLabelVerificationStrategy --- CHANGELOG.asciidoc | 2 +- docs/src/upgrade/release-3.3.x.asciidoc| 38 + .../tinkerpop/gremlin/jsr223/CoreImports.java | 2 + .../EdgeLabelVerificationStrategy.java | 130 ++ .../structure/io/graphson/GraphSONModule.java | 5 + .../gremlin/structure/io/gryo/GryoVersion.java | 7 +- .../EdgeLabelVerificationStrategyTest.java | 188 + 7 files changed, 369 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 88df8ad..106761a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima === TinkerPop 3.3.7 (Release Date: NOT OFFICIALLY RELEASED YET) * Ensure `gremlin.sh` works when directories contain spaces - +* Implemented `EdgeLabelVerificationStrategy` [[release-3-3-6]] === TinkerPop 3.3.6 (Release Date: March 18, 2019) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index c1911d3..a5ece72 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -27,6 +27,44 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima Please see the link:https://github.com/apache/tinkerpop/blob/3.3.7/CHANGELOG.asciidoc#release-3-3-7[changelog] for a complete list of all the modifications that are part of this release. +=== Upgrading for Providers + + Detection of Anti-Patterns + +This release adds a strategy named `EdgeLabelVerificationStrategy`. The strategy will not be added by default to the traversal source, however, providers can add it explicitly to encourage (or enforce) +users to always specify at least one edge label. `EdgeLabelVerificationStrategy` can be configured to either throw an exception if no edge label was specified, log a warning or do both. + +[source,text] + +gremlin> // throw an exception if edge label was not specified +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().throwException().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +Type ':help' or ':h' for help. +Display stack trace? [yN] + + +[source,text] + +gremlin> // log a warning if edge label was not specified (Log4j has to be configured properly) +gremlin> g = TinkerFactory.createModern().traversal().withStrategies(EdgeLabelVerificationStrategy.build().logWarning().create()) +==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] +gremlin> g.V(1).out('knows') +==>v[2] +==>v[4] +gremlin> g.V(1).out() +WARN org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy - The provided traversal contains a vertex step without any specified edge label: VertexStep(OUT,vertex) +==>v[3] +==>v[2] +==>v[4] + + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-2191[TINKERPOP-2191] + == TinkerPop 3.3.6 *Release Date: March 18, 2019* diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 576d0de..e298951 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -86,6 +86,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Orde import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; @@ -241,6 +242,7 @@ public final class CoreImports { CLASS_IMPORTS.add(LambdaRestrictionStrategy.class); CLASS_IMPORTS.add(ReadOnlyStrategy.class);
[tinkerpop] 01/01: Implemented EdgeLabelVerificationStrategy
This is an automated email from the ASF dual-hosted git repository. dkuppitz pushed a commit to branch TINKERPOP-2191 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git commit ee7433c076a7cc0d36fa3566d622bbe96a3d308f Author: Daniel Kuppitz AuthorDate: Thu Mar 14 15:05:09 2019 -0700 Implemented EdgeLabelVerificationStrategy --- .../tinkerpop/gremlin/jsr223/CoreImports.java | 2 + .../EdgeLabelVerificationStrategy.java | 130 ++ .../structure/io/graphson/GraphSONModule.java | 5 + .../gremlin/structure/io/gryo/GryoVersion.java | 7 +- .../EdgeLabelVerificationStrategyTest.java | 188 + 5 files changed, 330 insertions(+), 2 deletions(-) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 576d0de..e298951 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -86,6 +86,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Orde import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; @@ -241,6 +242,7 @@ public final class CoreImports { CLASS_IMPORTS.add(LambdaRestrictionStrategy.class); CLASS_IMPORTS.add(ReadOnlyStrategy.class); CLASS_IMPORTS.add(StandardVerificationStrategy.class); +CLASS_IMPORTS.add(EdgeLabelVerificationStrategy.class); // graph traversal CLASS_IMPORTS.add(AnonymousTraversalSource.class); CLASS_IMPORTS.add(__.class); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java new file mode 100644 index 000..a4fd804 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java @@ -0,0 +1,130 @@ +/* + * 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.verification; + +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.MapConfiguration; +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.map.VertexStep; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * {@code EdgeLabelVerificationStrategy} does not allow edge traversal steps to have no label specified. + * Providing one or more labels is considered to be a best practice, however, TinkerPop will not force the specification + * of edge labels; instead, providers or users will have to enable this strategy explicitly. + * + * + * @author Daniel Kuppitz (http://gremlin.guru) + * @example + * __.outE() // throws an IllegalStateException + * __.out()// throws an IllegalStateException + * __.bothE() // throws an IllegalStateException + * __.to(OUT) // throws an IllegalStateException + *
[tinkerpop] 01/01: Implemented EdgeLabelVerificationStrategy
This is an automated email from the ASF dual-hosted git repository. dkuppitz pushed a commit to branch TINKERPOP-2191 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git commit 21bfb55e12ffd86dad9de39bbaf155ae6bac39fc Author: Daniel Kuppitz AuthorDate: Thu Mar 14 15:05:09 2019 -0700 Implemented EdgeLabelVerificationStrategy --- .../tinkerpop/gremlin/jsr223/CoreImports.java | 2 + .../EdgeLabelVerificationStrategy.java | 130 ++ .../structure/io/graphson/GraphSONModule.java | 5 + .../gremlin/structure/io/gryo/GryoVersion.java | 7 +- .../EdgeLabelVerificationStrategyTest.java | 188 + 5 files changed, 330 insertions(+), 2 deletions(-) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index 576d0de..e298951 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -86,6 +86,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Orde import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; @@ -241,6 +242,7 @@ public final class CoreImports { CLASS_IMPORTS.add(LambdaRestrictionStrategy.class); CLASS_IMPORTS.add(ReadOnlyStrategy.class); CLASS_IMPORTS.add(StandardVerificationStrategy.class); +CLASS_IMPORTS.add(EdgeLabelVerificationStrategy.class); // graph traversal CLASS_IMPORTS.add(AnonymousTraversalSource.class); CLASS_IMPORTS.add(__.class); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java new file mode 100644 index 000..1b8876a --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/EdgeLabelVerificationStrategy.java @@ -0,0 +1,130 @@ +/* + * 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.verification; + +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.MapConfiguration; +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.map.VertexStep; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * {@code EdgeLabelVerificationStrategy} does not allow edge traversal steps to have no label specified. + * Providing one or more labels is considered to be a best practice, however, TinkerPop will not force the specification + * of edge labels; instead, providers or users will have to enable this strategy explicitly. + * + * + * @author Daniel Kujppitz (http://gremlin.guru) + * @example + * __.outE() // throws an IllegalStateException + * __.out()// throws an IllegalStateException + * __.bothE() // throws an IllegalStateException + * __.to(OUT) // throws an IllegalStateException + *