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

org.apache.tinkerpop.gremlin.ogm.paths.steps.EdgeStep.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.elements.Edge
import org.apache.tinkerpop.gremlin.ogm.elements.Vertex
import org.apache.tinkerpop.gremlin.ogm.paths.Path
import org.apache.tinkerpop.gremlin.ogm.paths.bound.*
import org.apache.tinkerpop.gremlin.ogm.paths.relationships.Relationship

interface EdgeStep> : Step {

    open class ToSingle>(
            private val relationship: Relationship.ToSingle
    ) : Step.ToSingle({ traverser ->

        traverser.traversal.map {
            traverser.graphMapper.serialize(it.get())
        }.outE(relationship.name).map {
            traverser.graphMapper.deserialize(it.get())
        }
    })

    open class ToOptional>(
            private val relationship: Relationship.ToOptional
    ) : Step.ToOptional({ traverser ->

        traverser.traversal.map {
            traverser.graphMapper.serialize(it.get())
        }.outE(relationship.name).map {
            traverser.graphMapper.deserialize(it.get())
        }
    })

    open class ToMany>(
            private val relationship: Relationship.ToMany
    ) : Step.ToMany({ traverser ->

        traverser.traversal.map {
            traverser.graphMapper.serialize(it.get())
        }.outE(relationship.name).map {
            traverser.graphMapper.deserialize(it.get())
        }
    })
}

infix fun > FROM.outE(relationship: Relationship.ToSingle) = SingleBoundPathToSingle(from = this, path = EdgeStep.ToSingle(relationship))
infix fun > Iterable.outE(relationship: Relationship.ToSingle) = BoundPathToSingle(froms = this, path = EdgeStep.ToSingle(relationship))

infix fun > FROM.outE(relationship: Relationship.ToOptional) = SingleBoundPathToOptional(from = this, path = EdgeStep.ToOptional(relationship))
infix fun > Iterable.outE(relationship: Relationship.ToOptional) = BoundPathToOptional(froms = this, path = EdgeStep.ToOptional(relationship))

infix fun > FROM.outE(relationship: Relationship.ToMany) = SingleBoundPathToMany(from = this, path = EdgeStep.ToMany(relationship))
infix fun > Iterable.outE(relationship: Relationship.ToMany) = BoundPathToMany(froms = this, path = EdgeStep.ToMany(relationship))

infix fun > Path.ToSingle.outE(relationship: Relationship.ToSingle): Path.ToSingle = to(EdgeStep.ToSingle(relationship))
infix fun > Path.ToSingle.outE(relationship: Relationship.ToOptional): Path.ToOptional = to(EdgeStep.ToOptional(relationship))
infix fun > Path.ToSingle.outE(relationship: Relationship.ToMany): Path.ToMany = to(EdgeStep.ToMany(relationship))

infix fun > Path.ToOptional.outE(relationship: Relationship.ToSingle): Path.ToOptional = to(EdgeStep.ToSingle(relationship))
infix fun > Path.ToOptional.outE(relationship: Relationship.ToOptional): Path.ToOptional = to(EdgeStep.ToOptional(relationship))
infix fun > Path.ToOptional.outE(relationship: Relationship.ToMany): Path.ToMany = to(EdgeStep.ToMany(relationship))

infix fun > Path.ToMany.outE(relationship: Relationship.ToSingle): Path.ToMany = to(EdgeStep.ToSingle(relationship))
infix fun > Path.ToMany.outE(relationship: Relationship.ToOptional): Path.ToMany = to(EdgeStep.ToOptional(relationship))
infix fun > Path.ToMany.outE(relationship: Relationship.ToMany): Path.ToMany = to(EdgeStep.ToMany(relationship))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy