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


import java.time.OffsetDateTime

import jooq.main.Public
import jooq.main.enums.KugEventStatusEnum
import jooq.main.keys.KUG_EVENT_PKEY
import jooq.main.keys.KUG_EVENT__KUG_EVENT_KUG_ID_FKEY
import jooq.main.keys.KUG_EVENT__KUG_EVENT_UPDATED_BY_FKEY
import jooq.main.tables.Kotliner.KotlinerPath
import jooq.main.tables.Kug.KugPath
import jooq.main.tables.records.KugEventRecord

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

        /**
         * The reference instance of <code>public.kug_event</code>
         */
        val KUG_EVENT: KugEvent = KugEvent()
    }

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

    /**
     * The column <code>public.kug_event.id</code>.
     */
    val ID: TableField<KugEventRecord, Long?> = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "")

    /**
     * The column <code>public.kug_event.created</code>.
     */
    val CREATED: TableField<KugEventRecord, OffsetDateTime?> = createField(DSL.name("created"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).nullable(false), this, "")

    /**
     * The column <code>public.kug_event.updated</code>.
     */
    val UPDATED: TableField<KugEventRecord, OffsetDateTime?> = createField(DSL.name("updated"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).nullable(false), this, "")

    /**
     * The column <code>public.kug_event.updated_by</code>.
     */
    val UPDATED_BY: TableField<KugEventRecord, Long?> = createField(DSL.name("updated_by"), SQLDataType.BIGINT.nullable(false), this, "")

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

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

    /**
     * The column <code>public.kug_event.title</code>.
     */
    val TITLE: TableField<KugEventRecord, String?> = createField(DSL.name("title"), SQLDataType.VARCHAR(500).nullable(false), this, "")

    /**
     * The column <code>public.kug_event.latitude</code>.
     */
    val LATITUDE: TableField<KugEventRecord, Double?> = createField(DSL.name("latitude"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.kug_event.longitude</code>.
     */
    val LONGITUDE: TableField<KugEventRecord, Double?> = createField(DSL.name("longitude"), SQLDataType.DOUBLE, this, "")

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

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

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

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

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

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

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class KugEventPath : KugEvent, Path<KugEventRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, KugEventRecord>?, parentPath: InverseForeignKey<out Record, KugEventRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<KugEventRecord>): super(alias, aliased)
        override fun `as`(alias: String): KugEventPath = KugEventPath(DSL.name(alias), this)
        override fun `as`(alias: Name): KugEventPath = KugEventPath(alias, this)
        override fun `as`(alias: Table<*>): KugEventPath = KugEventPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIdentity(): Identity<KugEventRecord, Long?> = super.getIdentity() as Identity<KugEventRecord, Long?>
    override fun getPrimaryKey(): UniqueKey<KugEventRecord> = KUG_EVENT_PKEY
    override fun getReferences(): List<ForeignKey<KugEventRecord, *>> = listOf(KUG_EVENT__KUG_EVENT_UPDATED_BY_FKEY, KUG_EVENT__KUG_EVENT_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_EVENT__KUG_EVENT_UPDATED_BY_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_EVENT__KUG_EVENT_KUG_ID_FKEY, null)

        return _kug;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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