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


import com.nisemoe.generated.Public
import com.nisemoe.generated.indexes.IDX_USERS_IS_BANNED_FALSE
import com.nisemoe.generated.indexes.IDX_USERS_IS_BANNED_TRUE
import com.nisemoe.generated.keys.USERS_PKEY
import com.nisemoe.generated.keys.USER_FOLLOWS__USER_FOLLOWS_FOLLOWS_USER_ID_FKEY
import com.nisemoe.generated.keys.USER_FOLLOWS__USER_FOLLOWS_USER_ID_FKEY
import com.nisemoe.generated.tables.UserFollows.UserFollowsPath
import com.nisemoe.generated.tables.records.UsersRecord

import java.time.LocalDateTime
import java.time.OffsetDateTime

import kotlin.collections.Collection
import kotlin.collections.List

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

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

    /**
     * The column <code>public.users.approx_ban_date</code>.
     */
    val APPROX_BAN_DATE: TableField<UsersRecord, OffsetDateTime?> = createField(DSL.name("approx_ban_date"), SQLDataType.TIMESTAMPWITHTIMEZONE(6), this, "")

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

    /**
     * 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(path: Table<out Record>, childPath: ForeignKey<out Record, UsersRecord>?, parentPath: InverseForeignKey<out Record, UsersRecord>?): this(Internal.createPathAlias(path, childPath, parentPath), path, childPath, parentPath, USERS, null, null)

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class UsersPath : Users, Path<UsersRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, UsersRecord>?, parentPath: InverseForeignKey<out Record, UsersRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<UsersRecord>): super(alias, aliased)
        override fun `as`(alias: String): UsersPath = UsersPath(DSL.name(alias), this)
        override fun `as`(alias: Name): UsersPath = UsersPath(alias, this)
        override fun `as`(alias: Table<*>): UsersPath = UsersPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIndexes(): List<Index> = listOf(IDX_USERS_IS_BANNED_FALSE, IDX_USERS_IS_BANNED_TRUE)
    override fun getPrimaryKey(): UniqueKey<UsersRecord> = USERS_PKEY

    private lateinit var _userFollowsFollowsUserIdFkey: UserFollowsPath

    /**
     * Get the implicit to-many join path to the
     * <code>public.user_follows</code> table, via the
     * <code>user_follows_follows_user_id_fkey</code> key
     */
    fun userFollowsFollowsUserIdFkey(): UserFollowsPath {
        if (!this::_userFollowsFollowsUserIdFkey.isInitialized)
            _userFollowsFollowsUserIdFkey = UserFollowsPath(this, null, USER_FOLLOWS__USER_FOLLOWS_FOLLOWS_USER_ID_FKEY.inverseKey)

        return _userFollowsFollowsUserIdFkey;
    }

    val userFollowsFollowsUserIdFkey: UserFollowsPath
        get(): UserFollowsPath = userFollowsFollowsUserIdFkey()

    private lateinit var _userFollowsUserIdFkey: UserFollowsPath

    /**
     * Get the implicit to-many join path to the
     * <code>public.user_follows</code> table, via the
     * <code>user_follows_user_id_fkey</code> key
     */
    fun userFollowsUserIdFkey(): UserFollowsPath {
        if (!this::_userFollowsUserIdFkey.isInitialized)
            _userFollowsUserIdFkey = UserFollowsPath(this, null, USER_FOLLOWS__USER_FOLLOWS_USER_ID_FKEY.inverseKey)

        return _userFollowsUserIdFkey;
    }

    val userFollowsUserIdFkey: UserFollowsPath
        get(): UserFollowsPath = userFollowsUserIdFkey()
    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.qualifiedName, 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.qualifiedName, null)

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

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

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

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

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

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

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

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

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

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