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


import com.nisemoe.generated.Public
import com.nisemoe.generated.keys.OSU_API_KEYS_PKEY
import com.nisemoe.generated.tables.records.OsuApiKeysRecord

import java.time.OffsetDateTime
import java.util.function.Function

import org.jooq.Field
import org.jooq.ForeignKey
import org.jooq.Identity
import org.jooq.Name
import org.jooq.Record
import org.jooq.Records
import org.jooq.Row5
import org.jooq.Schema
import org.jooq.SelectField
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 OsuApiKeys(
    alias: Name,
    child: Table<out Record>?,
    path: ForeignKey<out Record, OsuApiKeysRecord>?,
    aliased: Table<OsuApiKeysRecord>?,
    parameters: Array<Field<*>?>?
): TableImpl<OsuApiKeysRecord>(
    alias,
    Public.PUBLIC,
    child,
    path,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table()
) {
    companion object {

        /**
         * The reference instance of <code>public.osu_api_keys</code>
         */
        val OSU_API_KEYS: OsuApiKeys = OsuApiKeys()
    }

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

    /**
     * The column <code>public.osu_api_keys.id</code>.
     */
    val ID: TableField<OsuApiKeysRecord, Int?> = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "")

    /**
     * The column <code>public.osu_api_keys.api_key</code>.
     */
    val API_KEY: TableField<OsuApiKeysRecord, String?> = createField(DSL.name("api_key"), SQLDataType.CLOB.nullable(false), this, "")

    /**
     * The column <code>public.osu_api_keys.created_at</code>.
     */
    val CREATED_AT: TableField<OsuApiKeysRecord, OffsetDateTime?> = createField(DSL.name("created_at"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).nullable(false).defaultValue(DSL.field(DSL.raw("CURRENT_TIMESTAMP"), SQLDataType.TIMESTAMPWITHTIMEZONE)), this, "")

    /**
     * The column <code>public.osu_api_keys.is_valid</code>.
     */
    val IS_VALID: TableField<OsuApiKeysRecord, Boolean?> = createField(DSL.name("is_valid"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("true"), SQLDataType.BOOLEAN)), this, "")

    /**
     * The column <code>public.osu_api_keys.is_active</code>.
     */
    val IS_ACTIVE: TableField<OsuApiKeysRecord, Boolean?> = createField(DSL.name("is_active"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("true"), SQLDataType.BOOLEAN)), this, "")

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

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

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

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

    constructor(child: Table<out Record>, key: ForeignKey<out Record, OsuApiKeysRecord>): this(Internal.createPathAlias(child, key), child, key, OSU_API_KEYS, null)
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIdentity(): Identity<OsuApiKeysRecord, Int?> = super.getIdentity() as Identity<OsuApiKeysRecord, Int?>
    override fun getPrimaryKey(): UniqueKey<OsuApiKeysRecord> = OSU_API_KEYS_PKEY
    override fun `as`(alias: String): OsuApiKeys = OsuApiKeys(DSL.name(alias), this)
    override fun `as`(alias: Name): OsuApiKeys = OsuApiKeys(alias, this)
    override fun `as`(alias: Table<*>): OsuApiKeys = OsuApiKeys(alias.getQualifiedName(), this)

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

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

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

    // -------------------------------------------------------------------------
    // Row5 type methods
    // -------------------------------------------------------------------------
    override fun fieldsRow(): Row5<Int?, String?, OffsetDateTime?, Boolean?, Boolean?> = super.fieldsRow() as Row5<Int?, String?, OffsetDateTime?, Boolean?, Boolean?>

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    fun <U> mapping(from: (Int?, String?, OffsetDateTime?, Boolean?, Boolean?) -> U): SelectField<U> = convertFrom(Records.mapping(from))

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    fun <U> mapping(toType: Class<U>, from: (Int?, String?, OffsetDateTime?, Boolean?, Boolean?) -> U): SelectField<U> = convertFrom(toType, Records.mapping(from))
}
