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

org.apache.tinkerpop.gremlin.ogm.paths.steps.LinkedPath.kt Maven / Gradle / Ivy

There is a newer version: 0.21.0
Show newest version
package org.apache.tinkerpop.gremlin.ogm.paths.steps

import org.apache.tinkerpop.gremlin.ogm.paths.Path
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal

internal interface LinkedPath : Path {

    val first: Path

    val second: Path

    override fun path() = first.path() + second.path()

    override fun invoke(from: StepTraverser): GraphTraversal<*, TO> =
            second(StepTraverser(first(from), from.graphMapper))

    class ToSingle(
            override val first: Path.ToSingle,
            override val second: Path.ToSingle
    ) : LinkedPath, Path.ToSingle

    class ToOptional(
            override val first: Path.ToOne,
            override val second: Path.ToOne
    ) : LinkedPath, Path.ToOptional

    class ToMany(
            override val first: Path,
            override val second: Path
    ) : LinkedPath, Path.ToMany
}

fun  Path.ToMany.to(next: Path): Path.ToMany = LinkedPath.ToMany(first = this, second = next)

fun  Path.ToOptional.to(next: Path.ToOne): Path.ToOptional = LinkedPath.ToOptional(first = this, second = next)
fun  Path.ToOptional.to(next: Path.ToMany): Path.ToMany = LinkedPath.ToMany(first = this, second = next)

fun  Path.ToSingle.to(next: Path.ToSingle): Path.ToSingle = LinkedPath.ToSingle(first = this, second = next)
fun  Path.ToSingle.to(next: Path.ToOptional): Path.ToOptional = LinkedPath.ToOptional(first = this, second = next)
fun  Path.ToSingle.to(next: Path.ToMany): Path.ToMany = LinkedPath.ToMany(first = this, second = next)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy