/*
 * This file is generated by jOOQ.
 */
package com.nisemoe.generated.tables


import com.nisemoe.generated.Public
import com.nisemoe.generated.keys.USER_FOLLOWS_PKEY
import com.nisemoe.generated.keys.USER_FOLLOWS__USER_FOLLOWS_FOLLOWS_USER_ID_FKEY
import com.nisemoe.generated.keys.USER_FOLLOWS__USER_FOLLOWS_USER_ID_FKEY
import com.nisemoe.generated.tables.Users.UsersPath
import com.nisemoe.generated.tables.records.UserFollowsRecord

import kotlin.collections.Collection
import kotlin.collections.List

import org.jooq.Condition
import org.jooq.Field
import org.jooq.ForeignKey
import org.jooq.Identity
import org.jooq.InverseForeignKey
import org.jooq.Name
import org.jooq.Path
import org.jooq.PlainSQL
import org.jooq.QueryPart
import org.jooq.Record
import org.jooq.SQL
import org.jooq.Schema
import org.jooq.Select
import org.jooq.Stringly
import org.jooq.Table
import org.jooq.TableField
import org.jooq.TableOptions
import org.jooq.UniqueKey
import org.jooq.impl.DSL
import org.jooq.impl.Internal
import org.jooq.impl.SQLDataType
import org.jooq.impl.TableImpl


/**
 * This class is generated by jOOQ.
 */
@Suppress("UNCHECKED_CAST")
open class UserFollows(
    alias: Name,
    path: Table<out Record>?,
    childPath: ForeignKey<out Record, UserFollowsRecord>?,
    parentPath: InverseForeignKey<out Record, UserFollowsRecord>?,
    aliased: Table<UserFollowsRecord>?,
    parameters: Array<Field<*>?>?,
    where: Condition?
): TableImpl<UserFollowsRecord>(
    alias,
    Public.PUBLIC,
    path,
    childPath,
    parentPath,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table(),
    where,
) {
    companion object {

        /**
         * The reference instance of <code>public.user_follows</code>
         */
        val USER_FOLLOWS: UserFollows = UserFollows()
    }

    /**
     * The class holding records for this type
     */
    override fun getRecordType(): Class<UserFollowsRecord> = UserFollowsRecord::class.java

    /**
     * The column <code>public.user_follows.user_id</code>.
     */
    val USER_ID: TableField<UserFollowsRecord, Long?> = createField(DSL.name("user_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "")

    /**
     * The column <code>public.user_follows.follows_user_id</code>.
     */
    val FOLLOWS_USER_ID: TableField<UserFollowsRecord, Long?> = createField(DSL.name("follows_user_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "")

    private constructor(alias: Name, aliased: Table<UserFollowsRecord>?): this(alias, null, null, null, aliased, null, null)
    private constructor(alias: Name, aliased: Table<UserFollowsRecord>?, parameters: Array<Field<*>?>?): this(alias, null, null, null, aliased, parameters, null)
    private constructor(alias: Name, aliased: Table<UserFollowsRecord>?, where: Condition?): this(alias, null, null, null, aliased, null, where)

    /**
     * Create an aliased <code>public.user_follows</code> table reference
     */
    constructor(alias: String): this(DSL.name(alias))

    /**
     * Create an aliased <code>public.user_follows</code> table reference
     */
    constructor(alias: Name): this(alias, null)

    /**
     * Create a <code>public.user_follows</code> table reference
     */
    constructor(): this(DSL.name("user_follows"), null)

    constructor(path: Table<out Record>, childPath: ForeignKey<out Record, UserFollowsRecord>?, parentPath: InverseForeignKey<out Record, UserFollowsRecord>?): this(Internal.createPathAlias(path, childPath, parentPath), path, childPath, parentPath, USER_FOLLOWS, null, null)

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class UserFollowsPath : UserFollows, Path<UserFollowsRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, UserFollowsRecord>?, parentPath: InverseForeignKey<out Record, UserFollowsRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<UserFollowsRecord>): super(alias, aliased)
        override fun `as`(alias: String): UserFollowsPath = UserFollowsPath(DSL.name(alias), this)
        override fun `as`(alias: Name): UserFollowsPath = UserFollowsPath(alias, this)
        override fun `as`(alias: Table<*>): UserFollowsPath = UserFollowsPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIdentity(): Identity<UserFollowsRecord, Long?> = super.getIdentity() as Identity<UserFollowsRecord, Long?>
    override fun getPrimaryKey(): UniqueKey<UserFollowsRecord> = USER_FOLLOWS_PKEY
    override fun getReferences(): List<ForeignKey<UserFollowsRecord, *>> = listOf(USER_FOLLOWS__USER_FOLLOWS_USER_ID_FKEY, USER_FOLLOWS__USER_FOLLOWS_FOLLOWS_USER_ID_FKEY)

    private lateinit var _userFollowsUserIdFkey: UsersPath

    /**
     * Get the implicit join path to the <code>public.users</code> table, via
     * the <code>user_follows_user_id_fkey</code> key.
     */
    fun userFollowsUserIdFkey(): UsersPath {
        if (!this::_userFollowsUserIdFkey.isInitialized)
            _userFollowsUserIdFkey = UsersPath(this, USER_FOLLOWS__USER_FOLLOWS_USER_ID_FKEY, null)

        return _userFollowsUserIdFkey;
    }

    val userFollowsUserIdFkey: UsersPath
        get(): UsersPath = userFollowsUserIdFkey()

    private lateinit var _userFollowsFollowsUserIdFkey: UsersPath

    /**
     * Get the implicit join path to the <code>public.users</code> table, via
     * the <code>user_follows_follows_user_id_fkey</code> key.
     */
    fun userFollowsFollowsUserIdFkey(): UsersPath {
        if (!this::_userFollowsFollowsUserIdFkey.isInitialized)
            _userFollowsFollowsUserIdFkey = UsersPath(this, USER_FOLLOWS__USER_FOLLOWS_FOLLOWS_USER_ID_FKEY, null)

        return _userFollowsFollowsUserIdFkey;
    }

    val userFollowsFollowsUserIdFkey: UsersPath
        get(): UsersPath = userFollowsFollowsUserIdFkey()
    override fun `as`(alias: String): UserFollows = UserFollows(DSL.name(alias), this)
    override fun `as`(alias: Name): UserFollows = UserFollows(alias, this)
    override fun `as`(alias: Table<*>): UserFollows = UserFollows(alias.qualifiedName, this)

    /**
     * Rename this table
     */
    override fun rename(name: String): UserFollows = UserFollows(DSL.name(name), null)

    /**
     * Rename this table
     */
    override fun rename(name: Name): UserFollows = UserFollows(name, null)

    /**
     * Rename this table
     */
    override fun rename(name: Table<*>): UserFollows = UserFollows(name.qualifiedName, null)

    /**
     * Create an inline derived table from this table
     */
    override fun where(condition: Condition?): UserFollows = UserFollows(qualifiedName, if (aliased()) this else null, condition)

    /**
     * Create an inline derived table from this table
     */
    override fun where(conditions: Collection<Condition>): UserFollows = where(DSL.and(conditions))

    /**
     * Create an inline derived table from this table
     */
    override fun where(vararg conditions: Condition?): UserFollows = where(DSL.and(*conditions))

    /**
     * Create an inline derived table from this table
     */
    override fun where(condition: Field<Boolean?>?): UserFollows = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(condition: SQL): UserFollows = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String): UserFollows = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String, vararg binds: Any?): UserFollows = where(DSL.condition(condition, *binds))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String, vararg parts: QueryPart): UserFollows = where(DSL.condition(condition, *parts))

    /**
     * Create an inline derived table from this table
     */
    override fun whereExists(select: Select<*>): UserFollows = where(DSL.exists(select))

    /**
     * Create an inline derived table from this table
     */
    override fun whereNotExists(select: Select<*>): UserFollows = where(DSL.notExists(select))
}
