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/04/13 19:10:48 UTC
[2/4] incubator-tinkerpop git commit: Removed the Graph.Helper
annotation and related infrastructure given TINKERPOP3-412
Removed the Graph.Helper annotation and related infrastructure given TINKERPOP3-412
Since GraphStrategy is no longer present and wrappers are not the go-to method for introducing "strategy" there isn't cause for confusion here anymore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/5f1d8ecc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/5f1d8ecc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/5f1d8ecc
Branch: refs/heads/TINKERPOP3-581
Commit: 5f1d8ecce811f0363bbf1203db067bc6c143944f
Parents: fd5197d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Apr 13 11:35:04 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Apr 13 11:35:04 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/Element.java | 2 -
.../tinkerpop/gremlin/structure/Graph.java | 14 ----
.../tinkerpop/gremlin/structure/Property.java | 4 --
.../gremlin/structure/VertexProperty.java | 2 -
.../tinkerpop/gremlin/AbstractGremlinSuite.java | 71 --------------------
5 files changed, 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5f1d8ecc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Element.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Element.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Element.java
index 72df6e7..d2e94b9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Element.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Element.java
@@ -90,7 +90,6 @@ public abstract interface Element {
*
* @throws NoSuchElementException if the property does not exist on the {@code Element}.
*/
- @Graph.Helper
public default <V> V value(final String key) throws NoSuchElementException {
return this.<V>property(key).orElseThrow(() -> Property.Exceptions.propertyDoesNotExist(key));
}
@@ -104,7 +103,6 @@ public abstract interface Element {
/**
* Get the values of properties as an {@link Iterator}.
*/
- @Graph.Helper
public default <V> Iterator<V> values(final String... propertyKeys) {
return IteratorUtils.map(this.<V>properties(propertyKeys), property -> property.value());
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5f1d8ecc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index 9cbdba4..fef8517 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -132,7 +132,6 @@ public interface Graph extends AutoCloseable {
* @param label the label of the vertex
* @return The newly created labeled vertex
*/
- @Graph.Helper
public default Vertex addVertex(final String label) {
return this.addVertex(T.label, label);
}
@@ -373,7 +372,6 @@ public interface Graph extends AutoCloseable {
/**
* Gets the variables of the {@link Graph} as a {@code Map}.
*/
- @Graph.Helper
public default Map<String, Object> asMap() {
final Map<String, Object> map = keys().stream()
.map(key -> Pair.with(key, get(key).get()))
@@ -1145,16 +1143,4 @@ public interface Graph extends AutoCloseable {
public @interface OptOuts {
OptOut[] value();
}
-
- /**
- * Defines a method as a "helper method". These methods will usually be default methods in the
- * core structure interfaces. Any method marked with this annotation represent methods that should not
- * be implemented by vendors. The test suite will enforce this convention and create a failure situation
- * if violated.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- @Inherited
- public @interface Helper {
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5f1d8ecc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
index cf94618..7cd17ed 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
@@ -62,7 +62,6 @@ public interface Property<V> {
*
* @param consumer The consumer to process the existing value.
*/
- @Graph.Helper
public default void ifPresent(final Consumer<? super V> consumer) {
if (this.isPresent())
consumer.accept(this.value());
@@ -74,7 +73,6 @@ public interface Property<V> {
* @param otherValue The value to return if the property is not present
* @return A value
*/
- @Graph.Helper
public default V orElse(final V otherValue) {
return this.isPresent() ? this.value() : otherValue;
}
@@ -85,7 +83,6 @@ public interface Property<V> {
* @param valueSupplier The supplier to use to generate a value if the property is not present
* @return A value
*/
- @Graph.Helper
public default V orElseGet(final Supplier<? extends V> valueSupplier) {
return this.isPresent() ? this.value() : valueSupplier.get();
}
@@ -98,7 +95,6 @@ public interface Property<V> {
* @return A value
* @throws E if the property is not present, the exception is thrown
*/
- @Graph.Helper
public default <E extends Throwable> V orElseThrow(final Supplier<? extends E> exceptionSupplier) throws E {
if (this.isPresent()) return this.value();
else
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5f1d8ecc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexProperty.java
index 4bdad8f..bf641da 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexProperty.java
@@ -53,7 +53,6 @@ public interface VertexProperty<V> extends Property<V>, Element {
* {@inheritDoc}
*/
@Override
- @Graph.Helper
public default Graph graph() {
return this.element().graph();
}
@@ -62,7 +61,6 @@ public interface VertexProperty<V> extends Property<V>, Element {
* {@inheritDoc}
*/
@Override
- @Graph.Helper
public default String label() {
return this.key();
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5f1d8ecc/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinSuite.java
index 4ab600f..f988add 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinSuite.java
@@ -59,18 +59,6 @@ import java.util.stream.Stream;
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public abstract class AbstractGremlinSuite extends Suite {
-
- // todo: perhaps there is a test that validates against the implementations to be sure that the Graph constructed matches what's defined???
- private static final Set<Class> STRUCTURE_INTERFACES = new HashSet<Class>() {{
- add(Edge.class);
- add(Element.class);
- add(Graph.class);
- add(Graph.Variables.class);
- add(Property.class);
- add(Vertex.class);
- add(VertexProperty.class);
- }};
-
/**
* The GraphProvider instance that will be used to generate a Graph instance.
*/
@@ -127,9 +115,6 @@ public abstract class AbstractGremlinSuite extends Suite {
try {
final GraphProvider graphProvider = pair.getValue0().newInstance();
- validateStructureInterfacesRegistered(graphProvider);
- validateHelpersNotImplemented(graphProvider);
-
GraphManager.setGraphProvider(graphProvider);
GraphManager.setTraversalEngineType(traversalEngineType);
} catch (Exception ex) {
@@ -137,50 +122,6 @@ public abstract class AbstractGremlinSuite extends Suite {
}
}
- /**
- * Need to validate that structure interfaces are implemented so that checks to {@link Graph.Helper} can be
- * properly enforced.
- */
- private void validateStructureInterfacesRegistered(final GraphProvider graphProvider) throws Exception {
- final Set<Class> implementations = graphProvider.getImplementations();
- final Set<Class> noImplementationRegistered = new HashSet<>();
-
- final Configuration conf = graphProvider.newGraphConfiguration("prototype", AbstractGremlinSuite.class, "validateStructureInterfacesRegistered");
- final Graph graph = graphProvider.openTestGraph(conf);
- final Set<Class> structureInterfaces = new HashSet<>(STRUCTURE_INTERFACES);
-
- // not all graphs implement all features and therefore may not have implementations of certain "core" interfaces
- if (!graph.features().graph().variables().supportsVariables()) structureInterfaces.remove(Graph.Variables.class);
-
- graphProvider.clear(graph, conf);
-
- final boolean missingImplementations = structureInterfaces.stream().anyMatch(iface -> {
- final boolean noneMatch = implementations.stream().noneMatch(c -> iface.isAssignableFrom(c));
- if (noneMatch) noImplementationRegistered.add(iface);
- return noneMatch;
- });
-
- if (missingImplementations)
- throw new RuntimeException(String.format(
- "Implementations must register their implementations for the following interfaces %s",
- String.join(",", noImplementationRegistered.stream().map(Class::getName).collect(Collectors.toList()))));
- }
-
- private void validateHelpersNotImplemented(final GraphProvider graphProvider) {
- final List<String> overridenMethods = new ArrayList<>();
- graphProvider.getImplementations().forEach(clazz ->
- Stream.of(clazz.getDeclaredMethods())
- .filter(AbstractGremlinSuite::isHelperMethodOverriden)
- .map(m -> m.getDeclaringClass().getName() + "." + m.getName())
- .forEach(overridenMethods::add)
- );
-
- if (overridenMethods.size() > 0)
- throw new RuntimeException(String.format(
- "Implementations cannot override methods marked by @Helper annotation - check the following methods [%s]",
- String.join(",", overridenMethods)));
- }
-
private void validateOptInToSuite(final Class<? extends Graph> klass) throws InitializationError {
final Graph.OptIn[] optIns = klass.getAnnotationsByType(Graph.OptIn.class);
if (!gremlinFlavorSuite && !Arrays.stream(optIns).anyMatch(optIn -> optIn.value().equals(this.getClass().getCanonicalName())))
@@ -217,18 +158,6 @@ public abstract class AbstractGremlinSuite extends Suite {
return testsToExecute;
}
- public static boolean isHelperMethodOverriden(final Method myMethod) {
- final Class<?> declaringClass = myMethod.getDeclaringClass();
- for (Class<?> iface : declaringClass.getInterfaces()) {
- try {
- return iface.getMethod(myMethod.getName(), myMethod.getParameterTypes()).isAnnotationPresent(Graph.Helper.class);
- } catch (NoSuchMethodException ignored) {
- }
- }
-
- return false;
- }
-
public static Pair<Class<? extends GraphProvider>, Class<? extends Graph>> getGraphProviderClass(final Class<?> klass) throws InitializationError {
final GraphProviderClass annotation = klass.getAnnotation(GraphProviderClass.class);
if (null == annotation)