Skip to content

Commit

Permalink
Filled out JavaDoc for IdGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsh committed Mar 18, 2013
1 parent 2a873d4 commit 1a5bc56
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
Expand Up @@ -25,6 +25,7 @@
* <p/> * <p/>
* The base Graph must be an instance of KeyIndexableGraph. * The base Graph must be an instance of KeyIndexableGraph.
* It *may* be an instance of IndexableGraph, in which case its indices will be wrapped appropriately. * It *may* be an instance of IndexableGraph, in which case its indices will be wrapped appropriately.
* It *may* be an instance of TransactionalGraph, in which case transaction operations will be passed through.
* For those graphs which support vertex indices but not edge indices (or vice versa), * For those graphs which support vertex indices but not edge indices (or vice versa),
* you may configure IdGraph to use custom IDs only for vertices or only for edges. * you may configure IdGraph to use custom IDs only for vertices or only for edges.
* *
Expand All @@ -49,13 +50,19 @@ public class IdGraph<T extends KeyIndexableGraph> implements KeyIndexableGraph,
/** /**
* Adds custom ID functionality to the given graph, * Adds custom ID functionality to the given graph,
* supporting both custom vertex IDs and custom edge IDs. * supporting both custom vertex IDs and custom edge IDs.
* @param baseGraph the base graph which does not necessarily support custom IDs
*/ */
public IdGraph(final T baseGraph) { public IdGraph(final T baseGraph) {
this(baseGraph, true, true); this(baseGraph, true, true);
} }



/** /**
* Adds custom ID functionality to the given graph. * Adds custom ID functionality to the given graph,
* supporting either custom vertex IDs, custom edge IDs, or both.
* @param baseGraph the base graph which does not necessarily support custom IDs
* @param supportVertexIds whether to support custom vertex IDs
* @param supportEdgeIds whether to support custom edge IDs
*/ */
public IdGraph(final T baseGraph, public IdGraph(final T baseGraph,
final boolean supportVertexIds, final boolean supportVertexIds,
Expand Down Expand Up @@ -110,16 +117,6 @@ public IdFactory getEdgeIdFactory() {
return edgeIdFactory; return edgeIdFactory;
} }


private void createIndices() {
if (supportVertexIds && !baseGraph.getIndexedKeys(Vertex.class).contains(ID)) {
baseGraph.createKeyIndex(ID, Vertex.class);
}

if (supportEdgeIds && !baseGraph.getIndexedKeys(Edge.class).contains(ID)) {
baseGraph.createKeyIndex(ID, Edge.class);
}
}

public Features getFeatures() { public Features getFeatures() {
return features; return features;
} }
Expand Down Expand Up @@ -277,13 +274,6 @@ public void shutdown() {
baseGraph.shutdown(); baseGraph.shutdown();
} }


private static void verifyNativeElement(final Element e) {
if (!(e instanceof IdElement)) {
throw new IllegalArgumentException("given element was not created in this graph");
}
}

@Override
public String toString() { public String toString() {
return StringFactory.graphString(this, this.baseGraph.toString()); return StringFactory.graphString(this, this.baseGraph.toString());
} }
Expand Down Expand Up @@ -367,16 +357,6 @@ public void dropIndex(final String indexName) {
((IndexableGraph) baseGraph).dropIndex(indexName); ((IndexableGraph) baseGraph).dropIndex(indexName);
} }


private void verifyBaseGraphIsIndexableGraph() {
if (!(baseGraph instanceof IndexableGraph)) {
throw new IllegalStateException("base graph is not an indexable graph");
}
}

private boolean isVertexClass(final Class c) {
return Vertex.class.isAssignableFrom(c);
}

public GraphQuery query() { public GraphQuery query() {
final IdGraph idGraph = this; final IdGraph idGraph = this;
return new WrappedGraphQuery(this.baseGraph.query()) { return new WrappedGraphQuery(this.baseGraph.query()) {
Expand Down Expand Up @@ -412,4 +392,30 @@ public Object createId() {
return UUID.randomUUID().toString(); return UUID.randomUUID().toString();
} }
} }

private void verifyBaseGraphIsIndexableGraph() {
if (!(baseGraph instanceof IndexableGraph)) {
throw new IllegalStateException("base graph is not an indexable graph");
}
}

private boolean isVertexClass(final Class c) {
return Vertex.class.isAssignableFrom(c);
}

private void createIndices() {
if (supportVertexIds && !baseGraph.getIndexedKeys(Vertex.class).contains(ID)) {
baseGraph.createKeyIndex(ID, Vertex.class);
}

if (supportEdgeIds && !baseGraph.getIndexedKeys(Edge.class).contains(ID)) {
baseGraph.createKeyIndex(ID, Edge.class);
}
}

private static void verifyNativeElement(final Element e) {
if (!(e instanceof IdElement)) {
throw new IllegalArgumentException("given element was not created in this graph");
}
}
} }
Expand Up @@ -142,7 +142,7 @@ public GraphSail(final T graph, final String indexedPatterns) {
store.namespaces = store.addVertex(NAMESPACES_VERTEX_ID); store.namespaces = store.addVertex(NAMESPACES_VERTEX_ID);
} finally { } finally {
if (store.manualTransactions) { if (store.manualTransactions) {
((TransactionalGraph) graph).commit();; ((TransactionalGraph) graph).commit();
} }
} }
} }
Expand Down

0 comments on commit 1a5bc56

Please sign in to comment.