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


import com.nisemoe.generated.Public
import com.nisemoe.generated.keys.USERS_PKEY
import com.nisemoe.generated.tables.records.UsersRecord

import java.time.LocalDateTime
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.Row18
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 Users(
    alias: Name,
    child: Table<out Record>?,
    path: ForeignKey<out Record, UsersRecord>?,
    aliased: Table<UsersRecord>?,
    parameters: Array<Field<*>?>?
): TableImpl<UsersRecord>(
    alias,
    Public.PUBLIC,
    child,
    path,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table()
) {
    companion object {

        /**
         * The reference instance of <code>public.users</code>
         */
        val USERS: Users = Users()
    }

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

    /**
     * The column <code>public.users.user_id</code>.
     */
    val USER_ID: TableField<UsersRecord, Long?> = createField(DSL.name("user_id"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("nextval('users_user_id_seq1'::regclass)"), SQLDataType.BIGINT)), this, "")

    /**
     * The column <code>public.users.username</code>.
     */
    val USERNAME: TableField<UsersRecord, String?> = createField(DSL.name("username"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.users.join_date</code>.
     */
    val JOIN_DATE: TableField<UsersRecord, LocalDateTime?> = createField(DSL.name("join_date"), SQLDataType.LOCALDATETIME(6), this, "")

    /**
     * The column <code>public.users.country</code>.
     */
    val COUNTRY: TableField<UsersRecord, String?> = createField(DSL.name("country"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.users.country_rank</code>.
     */
    val COUNTRY_RANK: TableField<UsersRecord, Long?> = createField(DSL.name("country_rank"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.rank</code>.
     */
    val RANK: TableField<UsersRecord, Long?> = createField(DSL.name("rank"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.pp_raw</code>.
     */
    val PP_RAW: TableField<UsersRecord, Double?> = createField(DSL.name("pp_raw"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.users.accuracy</code>.
     */
    val ACCURACY: TableField<UsersRecord, Double?> = createField(DSL.name("accuracy"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.users.playcount</code>.
     */
    val PLAYCOUNT: TableField<UsersRecord, Long?> = createField(DSL.name("playcount"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.total_score</code>.
     */
    val TOTAL_SCORE: TableField<UsersRecord, Long?> = createField(DSL.name("total_score"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.ranked_score</code>.
     */
    val RANKED_SCORE: TableField<UsersRecord, Long?> = createField(DSL.name("ranked_score"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.seconds_played</code>.
     */
    val SECONDS_PLAYED: TableField<UsersRecord, Long?> = createField(DSL.name("seconds_played"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.count_100</code>.
     */
    val COUNT_100: TableField<UsersRecord, Long?> = createField(DSL.name("count_100"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.count_300</code>.
     */
    val COUNT_300: TableField<UsersRecord, Long?> = createField(DSL.name("count_300"), SQLDataType.BIGINT, this, "")

    /**
     * The column <code>public.users.count_50</code>.
     */
    val COUNT_50: TableField<UsersRecord, Long?> = createField(DSL.name("count_50"), SQLDataType.BIGINT, this, "")

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

    /**
     * The column <code>public.users.is_admin</code>.
     */
    val IS_ADMIN: TableField<UsersRecord, Boolean?> = createField(DSL.name("is_admin"), SQLDataType.BOOLEAN.defaultValue(DSL.field(DSL.raw("false"), SQLDataType.BOOLEAN)), this, "")

    /**
     * The column <code>public.users.count_miss</code>.
     */
    val COUNT_MISS: TableField<UsersRecord, Long?> = createField(DSL.name("count_miss"), SQLDataType.BIGINT, this, "")

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

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

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

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

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

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

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

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

    // -------------------------------------------------------------------------
    // Row18 type methods
    // -------------------------------------------------------------------------
    override fun fieldsRow(): Row18<Long?, String?, LocalDateTime?, String?, Long?, Long?, Double?, Double?, Long?, Long?, Long?, Long?, Long?, Long?, Long?, OffsetDateTime?, Boolean?, Long?> = super.fieldsRow() as Row18<Long?, String?, LocalDateTime?, String?, Long?, Long?, Double?, Double?, Long?, Long?, Long?, Long?, Long?, Long?, Long?, OffsetDateTime?, Boolean?, Long?>

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

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