/*
 * This file is generated by jOOQ.
 */
package jooq.main.tables


import java.time.LocalDate

import jooq.main.Public
import jooq.main.enums.KugMemberStatusEnum
import jooq.main.keys.KUG_MEMBER__KUG_MEMBER_KOTLINER_ID_FKEY
import jooq.main.keys.KUG_MEMBER__KUG_MEMBER_KUG_ID_FKEY
import jooq.main.keys.UNIQUE_KOTLINER_KUG
import jooq.main.tables.Kotliner.KotlinerPath
import jooq.main.tables.Kug.KugPath
import jooq.main.tables.records.KugMemberRecord

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

import org.jooq.Condition
import org.jooq.Field
import org.jooq.ForeignKey
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 KugMember(
    alias: Name,
    path: Table<out Record>?,
    childPath: ForeignKey<out Record, KugMemberRecord>?,
    parentPath: InverseForeignKey<out Record, KugMemberRecord>?,
    aliased: Table<KugMemberRecord>?,
    parameters: Array<Field<*>?>?,
    where: Condition?
): TableImpl<KugMemberRecord>(
    alias,
    Public.PUBLIC,
    path,
    childPath,
    parentPath,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table(),
    where,
) {
    companion object {

        /**
         * The reference instance of <code>public.kug_member</code>
         */
        val KUG_MEMBER: KugMember = KugMember()
    }

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

    /**
     * The column <code>public.kug_member.kotliner_id</code>.
     */
    val KOTLINER_ID: TableField<KugMemberRecord, Long?> = createField(DSL.name("kotliner_id"), SQLDataType.BIGINT.nullable(false), this, "")

    /**
     * The column <code>public.kug_member.kug_id</code>.
     */
    val KUG_ID: TableField<KugMemberRecord, Long?> = createField(DSL.name("kug_id"), SQLDataType.BIGINT.nullable(false), this, "")

    /**
     * The column <code>public.kug_member.role</code>.
     */
    val ROLE: TableField<KugMemberRecord, String?> = createField(DSL.name("role"), SQLDataType.VARCHAR(500).nullable(false), this, "")

    /**
     * The column <code>public.kug_member.join_date</code>.
     */
    val JOIN_DATE: TableField<KugMemberRecord, LocalDate?> = createField(DSL.name("join_date"), SQLDataType.LOCALDATE.nullable(false), this, "")

    /**
     * The column <code>public.kug_member.status</code>.
     */
    val STATUS: TableField<KugMemberRecord, KugMemberStatusEnum?> = createField(DSL.name("status"), SQLDataType.VARCHAR.nullable(false).asEnumDataType(KugMemberStatusEnum::class.java), this, "")

    /**
     * The column <code>public.kug_member.version</code>.
     */
    val VERSION: TableField<KugMemberRecord, Long?> = createField(DSL.name("version"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "")

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

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

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

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

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

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class KugMemberPath : KugMember, Path<KugMemberRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, KugMemberRecord>?, parentPath: InverseForeignKey<out Record, KugMemberRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<KugMemberRecord>): super(alias, aliased)
        override fun `as`(alias: String): KugMemberPath = KugMemberPath(DSL.name(alias), this)
        override fun `as`(alias: Name): KugMemberPath = KugMemberPath(alias, this)
        override fun `as`(alias: Table<*>): KugMemberPath = KugMemberPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getUniqueKeys(): List<UniqueKey<KugMemberRecord>> = listOf(UNIQUE_KOTLINER_KUG)
    override fun getReferences(): List<ForeignKey<KugMemberRecord, *>> = listOf(KUG_MEMBER__KUG_MEMBER_KOTLINER_ID_FKEY, KUG_MEMBER__KUG_MEMBER_KUG_ID_FKEY)

    private lateinit var _kotliner: KotlinerPath

    /**
     * Get the implicit join path to the <code>public.kotliner</code> table.
     */
    fun kotliner(): KotlinerPath {
        if (!this::_kotliner.isInitialized)
            _kotliner = KotlinerPath(this, KUG_MEMBER__KUG_MEMBER_KOTLINER_ID_FKEY, null)

        return _kotliner;
    }

    val kotliner: KotlinerPath
        get(): KotlinerPath = kotliner()

    private lateinit var _kug: KugPath

    /**
     * Get the implicit join path to the <code>public.kug</code> table.
     */
    fun kug(): KugPath {
        if (!this::_kug.isInitialized)
            _kug = KugPath(this, KUG_MEMBER__KUG_MEMBER_KUG_ID_FKEY, null)

        return _kug;
    }

    val kug: KugPath
        get(): KugPath = kug()
    override fun `as`(alias: String): KugMember = KugMember(DSL.name(alias), this)
    override fun `as`(alias: Name): KugMember = KugMember(alias, this)
    override fun `as`(alias: Table<*>): KugMember = KugMember(alias.qualifiedName, this)

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

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

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

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

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

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

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

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

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

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

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

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

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