@@ -1615,14 +1615,14 @@ public default GraphTraversal<S, E> from(final String fromStepLabel) {
16151615 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
16161616 * @since 3.8.0
16171617 */
1618- public default GraphTraversal <S , E > from (final GValue <Vertex > fromVertex ) {
1618+ public default GraphTraversal <S , E > from (final GValue <? > fromVertex ) {
16191619 final Step <?,?> prev = this .asAdmin ().getEndStep ();
16201620 if (!(prev instanceof FromToModulating ))
16211621 throw new IllegalArgumentException (String .format (
16221622 "The from() step cannot follow %s" , prev .getClass ().getSimpleName ()));
16231623
16241624 this .asAdmin ().getGremlinLang ().addStep (Symbols .from , fromVertex );
1625- ((FromToModulating ) prev ).addFrom (new GValueConstantTraversal <S , Vertex >(fromVertex ));
1625+ ((FromToModulating ) prev ).addFrom (new GValueConstantTraversal <>(fromVertex ));
16261626 return this ;
16271627 }
16281628
@@ -1636,150 +1636,98 @@ public default GraphTraversal<S, E> from(final GValue<Vertex> fromVertex) {
16361636 * @since 3.3.0
16371637 */
16381638 public default GraphTraversal <S , E > from (final Vertex fromVertex ) {
1639- final Step <?,?> prev = this .asAdmin ().getEndStep ();
1640- if (!(prev instanceof FromToModulating ))
1641- throw new IllegalArgumentException (String .format (
1642- "The from() step cannot follow %s" , prev .getClass ().getSimpleName ()));
1643-
1644- this .asAdmin ().getGremlinLang ().addStep (Symbols .from , fromVertex );
1645- ((FromToModulating ) prev ).addFrom (__ .constant (fromVertex ).asAdmin ());
1646- return this ;
1639+ return this .from (__ .V (fromVertex .id ()));
16471640 }
16481641
16491642 /**
16501643 * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
1651- * outgoing vertex of the newly added {@link Edge}.
1644+ * incoming vertex of the newly added {@link Edge}.
16521645 *
1653- * @param fromVertex the traversal for selecting the outgoing vertex
1646+ * @param toVertex the vertex for selecting the incoming vertex
16541647 * @return the traversal with the modified {@link AddEdgeStepContract}
16551648 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
1656- * @since 3.1.0-incubating
1649+ * @since 3.8.0
16571650 */
1658- public default GraphTraversal <S , E > from (final Traversal <?, Object > fromVertex ) {
1651+ public default GraphTraversal <S , E > to (final GValue <?> toVertex ) {
16591652 final Step <?,?> prev = this .asAdmin ().getEndStep ();
16601653 if (!(prev instanceof FromToModulating ))
16611654 throw new IllegalArgumentException (String .format (
1662- "The from () step cannot follow %s" , prev .getClass ().getSimpleName ()));
1655+ "The to () step cannot follow %s" , prev .getClass ().getSimpleName ()));
16631656
1664- this .asAdmin ().getGremlinLang ().addStep (Symbols .from , fromVertex );
1665- ((FromToModulating ) prev ).addFrom ( fromVertex . asAdmin ( ));
1657+ this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toVertex );
1658+ ((FromToModulating ) prev ).addTo ( new GValueConstantTraversal <>( toVertex ));
16661659 return this ;
16671660 }
16681661
16691662 /**
16701663 * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
16711664 * incoming vertex of the newly added {@link Edge}.
16721665 *
1673- * @param toVertex the vertex for selecting the incoming vertex
1666+ * @param toVertex the traversal for selecting the incoming vertex
16741667 * @return the traversal with the modified {@link AddEdgeStepContract}
16751668 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
1676- * @since 3.8.0
1669+ * @since 3.1.0-incubating
16771670 */
1678- public default GraphTraversal <S , E > to (final GValue < Vertex > toVertex ) {
1671+ public default GraphTraversal <S , E > to (final Traversal <?, ? > toVertex ) {
16791672 final Step <?,?> prev = this .asAdmin ().getEndStep ();
16801673 if (!(prev instanceof FromToModulating ))
16811674 throw new IllegalArgumentException (String .format (
16821675 "The to() step cannot follow %s" , prev .getClass ().getSimpleName ()));
16831676
16841677 this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toVertex );
1685- ((FromToModulating ) prev ).addTo (new GValueConstantTraversal < S , Vertex >( toVertex ));
1678+ ((FromToModulating ) prev ).addTo (toVertex . asAdmin ( ));
16861679 return this ;
16871680 }
16881681
16891682 /**
16901683 * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
16911684 * outgoing vertex of the newly added {@link Edge}.
16921685 *
1693- * @param fromVertexOrId the vertex for selecting the outgoing vertex
1686+ * @param fromVertex the traversal for selecting the outgoing vertex
16941687 * @return the traversal with the modified {@link AddEdgeStepContract}
16951688 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
1696- * @since 3.3.0
1697- */
1698- public default GraphTraversal <S , E > from (final Object fromVertexOrId ) {
1699- if (fromVertexOrId instanceof String ) {
1700- return this .from ((String ) fromVertexOrId );
1701- } else if (fromVertexOrId instanceof Traversal ) {
1702- this .from ((Traversal <?, Object >)fromVertexOrId );
1703- return this ;
1704- }
1705- final Step <?,?> prev = this .asAdmin ().getEndStep ();
1706- if (!(prev instanceof FromToModulating ))
1707- throw new IllegalArgumentException (String .format (
1708- "The from() step cannot follow %s" , prev .getClass ().getSimpleName ()));
1709-
1710- // Convert vertex to id for the purposes of GremlinLang
1711- Object fromId = fromVertexOrId instanceof Vertex ? ((Vertex ) fromVertexOrId ).id () : fromVertexOrId ;
1712- this .asAdmin ().getGremlinLang ().addStep (Symbols .from , fromId );
1713- ((FromToModulating ) prev ).addFrom (fromVertexOrId instanceof GValue ?
1714- new GValueConstantTraversal <>((GValue <Object >) fromVertexOrId ) :
1715- __ .constant (fromVertexOrId ).asAdmin ());
1716- return this ;
1717- }
1718-
1719- /**
1720- * Provide {@code to()}-modulation to respective steps.
1721- *
1722- * @param toStepLabel the step label to modulate to.
1723- * @return the traversal with the modified {@link FromToModulating} step.
1724- * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#to-step" target="_blank">Reference Documentation - To Step</a>
17251689 * @since 3.1.0-incubating
17261690 */
1727- public default GraphTraversal <S , E > to (final String toStepLabel ) {
1691+ public default GraphTraversal <S , E > from (final Traversal <?, ?> fromVertex ) {
17281692 final Step <?,?> prev = this .asAdmin ().getEndStep ();
17291693 if (!(prev instanceof FromToModulating ))
17301694 throw new IllegalArgumentException (String .format (
1731- "The to () step cannot follow %s" , prev .getClass ().getSimpleName ()));
1695+ "The from () step cannot follow %s" , prev .getClass ().getSimpleName ()));
17321696
1733- this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toStepLabel );
1734- ((FromToModulating ) prev ).addTo ( toStepLabel );
1697+ this .asAdmin ().getGremlinLang ().addStep (Symbols .from , fromVertex );
1698+ ((FromToModulating ) prev ).addFrom ( fromVertex . asAdmin () );
17351699 return this ;
17361700 }
17371701
17381702 /**
17391703 * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
17401704 * incoming vertex of the newly added {@link Edge}.
17411705 *
1742- * @param toVertex the traversal for selecting the incoming vertex
1743- * @return the traversal with the modified {@link AddEdgeStep }
1706+ * @param toVertex the vertex for selecting the incoming vertex
1707+ * @return the traversal with the modified {@link AddEdgeStepContract }
17441708 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
1745- * @since 3.1.0-incubating
1709+ * @since 3.8.0
17461710 */
1747- public default GraphTraversal <S , E > to (final Traversal <?, Object > toVertex ) {
1748- final Step <?,?> prev = this .asAdmin ().getEndStep ();
1749- if (!(prev instanceof FromToModulating ))
1750- throw new IllegalArgumentException (String .format (
1751- "The to() step cannot follow %s" , prev .getClass ().getSimpleName ()));
1752-
1753- this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toVertex );
1754- ((FromToModulating ) prev ).addTo (toVertex .asAdmin ());
1755- return this ;
1711+ public default GraphTraversal <S , E > to (final Vertex toVertex ) {
1712+ return this .to (__ .V (toVertex .id ()));
17561713 }
17571714
17581715 /**
1759- * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
1760- * incoming vertex of the newly added {@link Edge}.
1716+ * Provide {@code to()}-modulation to respective steps.
17611717 *
1762- * @param toVertexOrId the vertex for selecting the incoming vertex
1763- * @return the traversal with the modified {@link AddEdgeStep}
1764- * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge -step" target="_blank">Reference Documentation - From Step</a>
1765- * @since 3.3.0
1718+ * @param toStepLabel the step label to modulate to.
1719+ * @return the traversal with the modified {@link FromToModulating} step.
1720+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#to -step" target="_blank">Reference Documentation - To Step</a>
1721+ * @since 3.1.0-incubating
17661722 */
1767- public default GraphTraversal <S , E > to (final Object toVertexOrId ) {
1768- if (toVertexOrId instanceof String ) {
1769- return this .to ((String ) toVertexOrId );
1770- } else if (toVertexOrId instanceof Traversal ) {
1771- this .to ((Traversal <?, Object >)toVertexOrId );
1772- return this ;
1773- }
1723+ public default GraphTraversal <S , E > to (final String toStepLabel ) {
17741724 final Step <?,?> prev = this .asAdmin ().getEndStep ();
17751725 if (!(prev instanceof FromToModulating ))
17761726 throw new IllegalArgumentException (String .format (
17771727 "The to() step cannot follow %s" , prev .getClass ().getSimpleName ()));
17781728
1779- this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toVertexOrId );
1780- ((FromToModulating ) prev ).addTo (toVertexOrId instanceof GValue ?
1781- new GValueConstantTraversal <>((GValue <Object >) toVertexOrId ) :
1782- __ .constant (toVertexOrId ).asAdmin ());
1729+ this .asAdmin ().getGremlinLang ().addStep (Symbols .to , toStepLabel );
1730+ ((FromToModulating ) prev ).addTo (toStepLabel );
17831731 return this ;
17841732 }
17851733
0 commit comments