You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by mh...@apache.org on 2015/07/23 17:31:02 UTC

[07/16] incubator-tinkerpop git commit: Minor code changes in GraphFactory.

Minor code changes in GraphFactory.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/443e8af9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/443e8af9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/443e8af9

Branch: refs/heads/master
Commit: 443e8af92796a778701316938690917573533fff
Parents: 9d5826d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jul 22 11:51:03 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jul 22 11:51:03 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/util/GraphFactory.java    | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/443e8af9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphFactory.java
index 0a93095..89ab051 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphFactory.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphFactory.java
@@ -27,12 +27,11 @@ import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.configuration.XMLConfiguration;
 
 import java.io.File;
-import java.lang.annotation.Annotation;
 import java.util.Map;
 
 /**
  * Factory to construct new {@link org.apache.tinkerpop.gremlin.structure.Graph} instances from a
- * {@link org.apache.commons.configuration.Configuration} object or properties file.
+ * {@code Configuration} object or properties file.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -41,11 +40,11 @@ public final class GraphFactory {
     private GraphFactory() {}
 
     /**
-     * Open a graph.  See each {@link org.apache.tinkerpop.gremlin.structure.Graph} instance for its configuration options.
+     * Open a graph.  See each {@link Graph} instance for its configuration options.
      *
      * @param configuration A configuration object that specifies the minimally required properties for a                        I
-     *                      {@link org.apache.tinkerpop.gremlin.structure.Graph} instance. This minimum is determined by the
-     *                      {@link org.apache.tinkerpop.gremlin.structure.Graph} instance itself.
+     *                      {@link Graph} instance. This minimum is determined by the
+     *                      {@link Graph} instance itself.
      * @return A {@link org.apache.tinkerpop.gremlin.structure.Graph} instance.
      * @throws IllegalArgumentException if {@code configuration}
      */
@@ -57,26 +56,21 @@ public final class GraphFactory {
         if (null == clazz)
             throw new RuntimeException(String.format("Configuration must contain a valid '%s' setting", Graph.GRAPH));
 
-        Class<?> graphClass;
+        final Class<?> graphClass;
         try {
             graphClass = Class.forName(clazz);
         } catch (final ClassNotFoundException e) {
             throw new RuntimeException(String.format("GraphFactory could not find [%s] - Ensure that the jar is in the classpath", clazz));
         }
 
-        //If the graph class specifies a factory class then use that instead.
-        Class<?> factoryClass = graphClass;
-        GraphFactoryClass factoryAnnotation = graphClass.getAnnotation(GraphFactoryClass.class);
-        if(factoryAnnotation != null) {
-            factoryClass = factoryAnnotation.value();
-        }
-
+        // If the graph class specifies a factory class then use that instead of the specified class.
+        final GraphFactoryClass factoryAnnotation = graphClass.getAnnotation(GraphFactoryClass.class);
+        final Class<?> factoryClass = factoryAnnotation != null ? factoryAnnotation.value() : graphClass;
 
         return open(configuration, factoryClass);
-
     }
 
-    private static Graph open(Configuration configuration, Class<?> graphFactoryClass)
+    private static Graph open(final Configuration configuration, final Class<?> graphFactoryClass)
     {
         final Graph g;
         try {