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


import com.nisemoe.generated.Public
import com.nisemoe.generated.enums.JudgementType
import com.nisemoe.generated.indexes.IDX_SCORES_JUDGEMENTS_SCORE_ID
import com.nisemoe.generated.keys.SCORES_JUDGEMENTS_PKEY
import com.nisemoe.generated.keys.SCORES_JUDGEMENTS__SCORES_JUDGEMENTS_SCORE_ID_FKEY
import com.nisemoe.generated.tables.records.ScoresJudgementsRecord

import java.util.function.Function

import kotlin.collections.List

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

        /**
         * The reference instance of <code>public.scores_judgements</code>
         */
        val SCORES_JUDGEMENTS: ScoresJudgements = ScoresJudgements()
    }

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

    /**
     * The column <code>public.scores_judgements.id</code>.
     */
    val ID: TableField<ScoresJudgementsRecord, Int?> = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).defaultValue(DSL.field(DSL.raw("nextval('scores_judgements_id_seq1'::regclass)"), SQLDataType.INTEGER)), this, "")

    /**
     * The column <code>public.scores_judgements.time</code>.
     */
    val TIME: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("time"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.x</code>.
     */
    val X: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("x"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.y</code>.
     */
    val Y: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("y"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.type</code>.
     */
    val TYPE: TableField<ScoresJudgementsRecord, JudgementType?> = createField(DSL.name("type"), SQLDataType.VARCHAR.asEnumDataType(com.nisemoe.generated.enums.JudgementType::class.java), this, "")

    /**
     * The column <code>public.scores_judgements.distance_center</code>.
     */
    val DISTANCE_CENTER: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("distance_center"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.distance_edge</code>.
     */
    val DISTANCE_EDGE: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("distance_edge"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.error</code>.
     */
    val ERROR: TableField<ScoresJudgementsRecord, Double?> = createField(DSL.name("error"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.scores_judgements.score_id</code>.
     */
    val SCORE_ID: TableField<ScoresJudgementsRecord, Int?> = createField(DSL.name("score_id"), SQLDataType.INTEGER, this, "")

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

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

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

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

    constructor(child: Table<out Record>, key: ForeignKey<out Record, ScoresJudgementsRecord>): this(Internal.createPathAlias(child, key), child, key, SCORES_JUDGEMENTS, null)
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIndexes(): List<Index> = listOf(IDX_SCORES_JUDGEMENTS_SCORE_ID)
    override fun getPrimaryKey(): UniqueKey<ScoresJudgementsRecord> = SCORES_JUDGEMENTS_PKEY
    override fun getReferences(): List<ForeignKey<ScoresJudgementsRecord, *>> = listOf(SCORES_JUDGEMENTS__SCORES_JUDGEMENTS_SCORE_ID_FKEY)

    private lateinit var _scores: Scores

    /**
     * Get the implicit join path to the <code>public.scores</code> table.
     */
    fun scores(): Scores {
        if (!this::_scores.isInitialized)
            _scores = Scores(this, SCORES_JUDGEMENTS__SCORES_JUDGEMENTS_SCORE_ID_FKEY)

        return _scores;
    }

    val scores: Scores
        get(): Scores = scores()
    override fun `as`(alias: String): ScoresJudgements = ScoresJudgements(DSL.name(alias), this)
    override fun `as`(alias: Name): ScoresJudgements = ScoresJudgements(alias, this)
    override fun `as`(alias: Table<*>): ScoresJudgements = ScoresJudgements(alias.getQualifiedName(), this)

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

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

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

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

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

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