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

org.apache.tinkerpop.gremlin.ogm.paths.relationships.Link.kt Maven / Gradle / Ivy

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

import org.apache.tinkerpop.gremlin.ogm.elements.Vertex

/**
 * Links two [Connection]s as one.
 */
internal interface Link: Connection {

    /**
     * The first half of the linked connection.
     */
    val first: Connection

    /**
     * The second half of the linked connection.
     */
    val last: Connection

    override val inverse: Link

    override fun relationships(): List> = first.relationships() + last.relationships()

    class OptionalToOptional(
            override val first: Connection.OneToOne,
            override val last: Connection.OneToOne
    ) : Link, Connection.OptionalToOptional {

        override val inverse: OptionalToOptional
            get() = OptionalToOptional(first = last.inverse, last = first.inverse)
    }

    class OptionalToSingle(
            override val first: Connection.OneToSingle,
            override val last: Connection.OneToSingle
    ) : Link, Connection.OptionalToSingle {

        override val inverse: SingleToOptional
            get() = SingleToOptional(first = last.inverse, last = first.inverse)
    }

    class SingleToOptional(
            override val first: Connection.SingleToOne,
            override val last: Connection.SingleToOne
    ) : Link, Connection.SingleToOptional {

        override val inverse: OptionalToSingle
            get() = OptionalToSingle(first = last.inverse, last = first.inverse)
    }

    class SingleToSingle(
            override val first: Connection.SingleToSingle,
            override val last: Connection.SingleToSingle
    ) : Link, Connection.SingleToSingle {

        override val inverse: SingleToSingle
            get() = SingleToSingle(first = last.inverse, last = first.inverse)
    }

    class OptionalToMany(
            override val first: Connection.FromOne,
            override val last: Connection.FromOne
    ) : Link, Connection.OptionalToMany {

        override val inverse: ManyToOptional
            get() = ManyToOptional(first = last.inverse, last = first.inverse)
    }

    class SingleToMany(
            override val first: Connection.FromSingle,
            override val last: Connection.FromSingle
    ) : Link, Connection.SingleToMany {

        override val inverse: ManyToSingle
            get() = ManyToSingle(first = last.inverse, last = first.inverse)
    }

    class ManyToOptional(
            override val first: Connection.ToOne,
            override val last: Connection.ToOne
    ) : Link, Connection.ManyToOptional {

        override val inverse: OptionalToMany
            get() = OptionalToMany(first = last.inverse, last = first.inverse)
    }

    class ManyToSingle(
            override val first: Connection.ToSingle,
            override val last: Connection.ToSingle
    ) : Link, Connection.ManyToSingle {

        override val inverse: SingleToMany
            get() = SingleToMany(first = last.inverse, last = first.inverse)
    }

    class ManyToMany(
            override val first: Connection,
            override val last: Connection
    ) : Link, Connection.ManyToMany {

        override val inverse: ManyToMany
            get() = ManyToMany(first = last.inverse, last = first.inverse)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy