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


import com.nisemoe.generated.Public
import com.nisemoe.generated.keys.BEATMAPS_PKEY
import com.nisemoe.generated.tables.records.BeatmapsRecord

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

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

        /**
         * The reference instance of <code>public.beatmaps</code>
         */
        val BEATMAPS: Beatmaps = Beatmaps()
    }

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

    /**
     * The column <code>public.beatmaps.beatmap_id</code>.
     */
    val BEATMAP_ID: TableField<BeatmapsRecord, Int?> = createField(DSL.name("beatmap_id"), SQLDataType.INTEGER.nullable(false).defaultValue(DSL.field(DSL.raw("nextval('beatmaps_beatmap_id_seq1'::regclass)"), SQLDataType.INTEGER)), this, "")

    /**
     * The column <code>public.beatmaps.artist</code>.
     */
    val ARTIST: TableField<BeatmapsRecord, String?> = createField(DSL.name("artist"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.beatmaps.beatmapset_id</code>.
     */
    val BEATMAPSET_ID: TableField<BeatmapsRecord, Int?> = createField(DSL.name("beatmapset_id"), SQLDataType.INTEGER, this, "")

    /**
     * The column <code>public.beatmaps.creator</code>.
     */
    val CREATOR: TableField<BeatmapsRecord, String?> = createField(DSL.name("creator"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.beatmaps.source</code>.
     */
    val SOURCE: TableField<BeatmapsRecord, String?> = createField(DSL.name("source"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.beatmaps.star_rating</code>.
     */
    val STAR_RATING: TableField<BeatmapsRecord, Double?> = createField(DSL.name("star_rating"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.beatmaps.title</code>.
     */
    val TITLE: TableField<BeatmapsRecord, String?> = createField(DSL.name("title"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.beatmaps.version</code>.
     */
    val VERSION: TableField<BeatmapsRecord, String?> = createField(DSL.name("version"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.beatmaps.sys_last_update</code>.
     */
    val SYS_LAST_UPDATE: TableField<BeatmapsRecord, OffsetDateTime?> = createField(DSL.name("sys_last_update"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).defaultValue(DSL.field(DSL.raw("CURRENT_TIMESTAMP"), SQLDataType.TIMESTAMPWITHTIMEZONE)), this, "")

    /**
     * The column <code>public.beatmaps.last_replay_check</code>.
     */
    val LAST_REPLAY_CHECK: TableField<BeatmapsRecord, String?> = createField(DSL.name("last_replay_check"), SQLDataType.CLOB, this, "")

    /**
     * The column <code>public.beatmaps.beatmap_file</code>.
     */
    val BEATMAP_FILE: TableField<BeatmapsRecord, String?> = createField(DSL.name("beatmap_file"), SQLDataType.CLOB, this, "")

    /**
     * The column <code>public.beatmaps.beatmap_hash</code>.
     */
    val BEATMAP_HASH: TableField<BeatmapsRecord, String?> = createField(DSL.name("beatmap_hash"), SQLDataType.VARCHAR(32), this, "")

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

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

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

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

    constructor(child: Table<out Record>, key: ForeignKey<out Record, BeatmapsRecord>): this(Internal.createPathAlias(child, key), child, key, BEATMAPS, null)
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getPrimaryKey(): UniqueKey<BeatmapsRecord> = BEATMAPS_PKEY
    override fun `as`(alias: String): Beatmaps = Beatmaps(DSL.name(alias), this)
    override fun `as`(alias: Name): Beatmaps = Beatmaps(alias, this)
    override fun `as`(alias: Table<*>): Beatmaps = Beatmaps(alias.getQualifiedName(), this)

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

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

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

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

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

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