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


import com.nisemoe.generated.Public
import com.nisemoe.generated.keys.REDDIT_POST_PKEY
import com.nisemoe.generated.tables.records.RedditPostRecord

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

        /**
         * The reference instance of <code>public.reddit_post</code>
         */
        val REDDIT_POST: RedditPost = RedditPost()
    }

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

    /**
     * The column <code>public.reddit_post.post_id</code>.
     */
    val POST_ID: TableField<RedditPostRecord, String?> = createField(DSL.name("post_id"), SQLDataType.VARCHAR.nullable(false), this, "")

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

    /**
     * The column <code>public.reddit_post.created_utc</code>.
     */
    val CREATED_UTC: TableField<RedditPostRecord, Double?> = createField(DSL.name("created_utc"), SQLDataType.DOUBLE, this, "")

    /**
     * The column <code>public.reddit_post.url</code>.
     */
    val URL: TableField<RedditPostRecord, String?> = createField(DSL.name("url"), SQLDataType.VARCHAR, this, "")

    /**
     * The column <code>public.reddit_post.is_checked</code>.
     */
    val IS_CHECKED: TableField<RedditPostRecord, Boolean?> = createField(DSL.name("is_checked"), SQLDataType.BOOLEAN.defaultValue(DSL.field(DSL.raw("false"), SQLDataType.BOOLEAN)), this, "")

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

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

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

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

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

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

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

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

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

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

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