All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinkerpop.gremlin.structure.Edge Maven / Gradle / Ivy

package com.tinkerpop.gremlin.structure;

import com.tinkerpop.gremlin.process.T;
import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.Traverser;
import com.tinkerpop.gremlin.process.graph.GraphTraversal;
import com.tinkerpop.gremlin.process.graph.step.map.StartStep;
import com.tinkerpop.gremlin.util.function.SBiPredicate;
import com.tinkerpop.gremlin.util.function.SConsumer;
import com.tinkerpop.gremlin.util.function.SFunction;
import com.tinkerpop.gremlin.util.function.SPredicate;

import java.util.Iterator;
import java.util.Map;

/**
 * An {@link Edge} links two {@link Vertex} objects. Along with its {@link Property} objects, an {@link Edge} has both
 * a {@link Direction} and a {@code label}. The {@link Direction} determines which {@link Vertex} is the tail
 * {@link Vertex} (out {@link Vertex}) and which {@link Vertex} is the head {@link Vertex}
 * (in {@link Vertex}). The {@link Edge} {@code label} determines the type of relationship that exists between the
 * two vertices.
 * 

* Diagrammatically: *

 * outVertex ---label---> inVertex.
 * 
* * @author Marko A. Rodriguez (http://markorodriguez.com) * @author Joshua Shinavier (http://fortytwo.net) */ public interface Edge extends Element { /** * The default label to use for an edge. * This is typically never used as when an edge is created, an edge label is required to be specified. */ public static final String DEFAULT_LABEL = "edge"; /** * Retrieve the vertex (or vertices) associated with this edge as defined by the direction. * * @param direction Get the incoming vertex, outgoing vertex, or both vertices * @return An iterator with 1 or 2 vertices */ public Iterator vertices(final Direction direction); // element steps /////////////////////////////////////////////////////////// public default GraphTraversal toV(final Direction direction) { return this.start().toV(direction); } public default GraphTraversal inV() { return this.toV(Direction.IN); } public default GraphTraversal outV() { return this.toV(Direction.OUT); } public default GraphTraversal bothV() { return this.toV(Direction.BOTH); } public default GraphTraversal aggregate(final SFunction preAggregateFunction) { return this.start().aggregate(preAggregateFunction); } public default GraphTraversal aggregate() { return this.start().aggregate(); } public default GraphTraversal store(final SFunction preStoreFunction) { return this.start().store(preStoreFunction); } public default GraphTraversal store() { return this.start().store(); } public default GraphTraversal as(final String as) { return this.start().as(as); } public default GraphTraversal filter(final SPredicate> predicate) { return this.start().filter(predicate); } public default GraphTraversal flatMap(final SFunction, Iterator> function) { return this.start().flatMap(function); } public default GraphTraversal has(final String key) { return this.start().has(key); } public default GraphTraversal has(final String key, final Object value) { return this.start().has(key, value); } public default GraphTraversal has(final String key, final T t, final Object value) { return this.start().has(key, t, value); } public default GraphTraversal has(final String key, final SBiPredicate predicate, final Object value) { return this.start().has(key, predicate, value); } public default GraphTraversal hasNot(final String key) { return this.start().hasNot(key); } public default GraphTraversal interval(final String key, final Comparable startValue, final Comparable endValue) { return this.start().interval(key, startValue, endValue); } public default GraphTraversal identity() { return this.start().identity(); } public default GraphTraversal jump(final String as) { return this.start().jump(as); } public default GraphTraversal jump(final String as, final SPredicate> ifPredicate) { return this.start().jump(as, ifPredicate); } public default GraphTraversal jump(final String as, final SPredicate> ifPredicate, final SPredicate> emitPredicate) { return this.start().jump(as, ifPredicate, emitPredicate); } public default GraphTraversal map(final SFunction, E2> function) { return this.start().map(function); } public default GraphTraversal> match(final String inAs, final Traversal... traversals) { return (GraphTraversal) this.start().match(inAs, traversals); } public default GraphTraversal sideEffect(final SConsumer> consumer) { return this.start().sideEffect(consumer); } public default GraphTraversal choose(final SPredicate> choosePredicate, final Traversal trueChoice, final Traversal falseChoice) { return this.start().choose(choosePredicate, trueChoice, falseChoice); } public default GraphTraversal choose(final SFunction, M> mapFunction, final Map> choices) { return this.start().choose(mapFunction, choices); } public default GraphTraversal with(final Object... variableValues) { return this.start().with(variableValues); } public default GraphTraversal start() { final GraphTraversal traversal = GraphTraversal.of(); return (GraphTraversal) traversal.addStep(new StartStep<>(traversal, this)); } /////////////// /** * Common exceptions to use with an edge. */ public static class Exceptions extends Element.Exceptions { public static IllegalArgumentException edgeLabelCanNotBeNull() { return new IllegalArgumentException("Edge label can not be null"); } public static UnsupportedOperationException userSuppliedIdsNotSupported() { return new UnsupportedOperationException("Edge does not support user supplied identifiers"); } public static IllegalStateException edgeRemovalNotSupported() { return new IllegalStateException("Edge removal are not supported"); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy