public class GremlinUtils
extends java.lang.Object
| Constructor and Description |
|---|
GremlinUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.tinkerpop.gremlin.structure.Edge |
ensureEdgeExists(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Searches for an
Edge between the given source and target vertices and returns it, creating a new one if it does not exist. |
static org.apache.tinkerpop.gremlin.structure.Edge |
getEdge(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Finds and returns the single
Edge that connects the given source Vertex with the
given target Vertex. |
static java.util.Set<org.apache.tinkerpop.gremlin.structure.Edge> |
getEdges(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Finds and returns the
Edges that connects the given source Vertex with the given
target Vertex. |
static org.apache.tinkerpop.gremlin.structure.Edge |
setEdgeTarget(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Makes sure that only a single outgoing
Edge with the given label exists in the
source Vertex and that edge connects to the target Vertex. |
static java.util.List<org.apache.tinkerpop.gremlin.structure.Edge> |
setEdgeTargets(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
java.util.List<org.apache.tinkerpop.gremlin.structure.Vertex> targets)
A variant of
setEdgeTargets(Vertex, String, Set) that respects target ordering and non-uniqueness of
targets. |
static java.util.Set<org.apache.tinkerpop.gremlin.structure.Edge> |
setEdgeTargets(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
java.util.Set<org.apache.tinkerpop.gremlin.structure.Vertex> targets)
Makes sure that every edge with the given
label that is outgoing from the given
source vertex leads to one of the given targets, and that there is
one edge for each target. |
public static org.apache.tinkerpop.gremlin.structure.Edge setEdgeTarget(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Edge with the given label exists in the
source Vertex and that edge connects to the target Vertex.
There are several cases:
source - The source vertex that owns the edge to override. Must not be null.label - The label of the single edge. Must not be null.target - The target vertex to which the single edge should connect. Must not be null.public static java.util.Set<org.apache.tinkerpop.gremlin.structure.Edge> setEdgeTargets(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
java.util.Set<org.apache.tinkerpop.gremlin.structure.Vertex> targets)
label that is outgoing from the given
source vertex leads to one of the given targets, and that there is
one edge for each target.
This method is a two-step process.
source vertex, iterate over the outgoing edges that have the given label.
targets set, keep the edge and add it to
the result set.
targets set, delete it.
targets that we did not find in the previous step, create a new edge from
the source vertex with the given label, and add it to the result set.
source - The source vertex that owns the edge to override. Must not be null.label - The edge label in question. Must not be null.targets - The desired set of target vertices. May be empty (in which case all outgoing edges from the source
vertex will be deleted and the result set will be empty), but must not be null.targets set was empty, but will never be null.public static java.util.List<org.apache.tinkerpop.gremlin.structure.Edge> setEdgeTargets(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
java.util.List<org.apache.tinkerpop.gremlin.structure.Vertex> targets)
setEdgeTargets(Vertex, String, Set) that respects target ordering and non-uniqueness of
targets.
This method will check if there is an Edge from the given source Vertex to each of
the given target vertices. If the list of targets contains one vertex several times, this method
will ensure that there are as many edges to that target. Any outgoing edge from the given source
with the given label that is not reused by this process will be deleted. Additional edges
will be created only if necessary. The returned list of edges will be ordered by target vertex, and have the same
ordering as the given list of targets.
source - The source vertex that owns the edge to override. Must not be null.label - The edge label in question. Must not be null.targets - The desired list of target vertices. May be empty (in which case all outgoing edges from the source
vertex will be deleted and the result set will be empty), but must not be null. Multiple
occurrences of the same vertex will be respected, as well as the ordering of vertices in the list.targets set was empty, but will never be null.public static org.apache.tinkerpop.gremlin.structure.Edge getEdge(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Edge that connects the given source Vertex with the
given target Vertex.source - The source vertex of the edge to look for. Must not be null.label - The label of the edge to look for. Must not be null.target - The target vertex of the edge to look for. Must not be null.null if no such edge exists.java.lang.IllegalArgumentException - Thrown if there is more than one edge with the given label from the given source to the given target
vertex.public static java.util.Set<org.apache.tinkerpop.gremlin.structure.Edge> getEdges(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Edges that connects the given source Vertex with the given
target Vertex.source - The source vertex of the edge to look for. Must not be null.label - The label of the edge to look for. Must not be null.target - The target vertex of the edge to look for. Must not be null.null.public static org.apache.tinkerpop.gremlin.structure.Edge ensureEdgeExists(org.apache.tinkerpop.gremlin.structure.Vertex source,
java.lang.String label,
org.apache.tinkerpop.gremlin.structure.Vertex target)
Edge between the given source and target vertices and returns it, creating a new one if it does not exist.source - The source vertex. Must not be null.label - The edge label. Must not be null.target - The target vertex. Must not be null.